-
Notifications
You must be signed in to change notification settings - Fork 850
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update dependency io.zipkin.reporter2:zipkin-reporter-bom to 3.1.1 #6129
Merged
jack-berg
merged 1 commit into
open-telemetry:main
from
codefromthecrypt:zipkin-reporter-3
Jan 12, 2024
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 5 additions & 1 deletion
6
docs/apidiffs/current_vs_latest/opentelemetry-exporter-zipkin.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,6 @@ | ||
Comparing source compatibility of against | ||
No changes. | ||
*** MODIFIED CLASS: PUBLIC FINAL io.opentelemetry.exporter.zipkin.ZipkinSpanExporterBuilder (not serializable) | ||
=== CLASS FILE FORMAT VERSION: 52.0 <- 52.0 | ||
=== UNCHANGED METHOD: PUBLIC io.opentelemetry.exporter.zipkin.ZipkinSpanExporterBuilder setEncoder(zipkin2.codec.BytesEncoder<zipkin2.Span><zipkin2.Span>) | ||
+++ NEW ANNOTATION: java.lang.Deprecated | ||
+++ NEW METHOD: PUBLIC(+) io.opentelemetry.exporter.zipkin.ZipkinSpanExporterBuilder setEncoder(zipkin2.reporter.BytesEncoder<zipkin2.Span>) |
58 changes: 58 additions & 0 deletions
58
exporters/zipkin/src/main/java/io/opentelemetry/exporter/zipkin/BytesEncoderAdapter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
/* | ||
* Copyright The OpenTelemetry Authors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package io.opentelemetry.exporter.zipkin; | ||
|
||
import zipkin2.Span; | ||
import zipkin2.reporter.BytesEncoder; | ||
import zipkin2.reporter.Encoding; | ||
|
||
/** | ||
* This supports the deprecated method {@link | ||
* ZipkinSpanExporterBuilder#setEncoder(zipkin2.codec.BytesEncoder)}. | ||
*/ | ||
final class BytesEncoderAdapter implements BytesEncoder<Span> { | ||
private final zipkin2.codec.BytesEncoder<Span> delegate; | ||
private final Encoding encoding; | ||
|
||
@SuppressWarnings("deprecation") // we have to use the deprecated thrift encoding to return it | ||
BytesEncoderAdapter(zipkin2.codec.BytesEncoder<Span> delegate) { | ||
this.delegate = delegate; | ||
switch (delegate.encoding()) { | ||
case JSON: | ||
this.encoding = Encoding.JSON; | ||
break; | ||
case PROTO3: | ||
this.encoding = Encoding.PROTO3; | ||
break; | ||
case THRIFT: | ||
this.encoding = Encoding.THRIFT; | ||
break; | ||
default: | ||
// Only possible if zipkin2 adds an encoding besides above, which is very unlikely. | ||
throw new UnsupportedOperationException("unsupported encoding " + delegate.encoding()); | ||
Check warning on line 35 in exporters/zipkin/src/main/java/io/opentelemetry/exporter/zipkin/BytesEncoderAdapter.java Codecov / codecov/patchexporters/zipkin/src/main/java/io/opentelemetry/exporter/zipkin/BytesEncoderAdapter.java#L35
|
||
} | ||
} | ||
|
||
@Override | ||
public Encoding encoding() { | ||
return encoding; | ||
} | ||
|
||
@Override | ||
public int sizeInBytes(Span span) { | ||
return delegate.sizeInBytes(span); | ||
} | ||
|
||
@Override | ||
public byte[] encode(Span span) { | ||
return delegate.encode(span); | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return delegate.toString(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
70 changes: 70 additions & 0 deletions
70
exporters/zipkin/src/test/java/io/opentelemetry/exporter/zipkin/BytesEncoderAdapterTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
/* | ||
* Copyright The OpenTelemetry Authors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package io.opentelemetry.exporter.zipkin; | ||
|
||
import static io.opentelemetry.exporter.zipkin.ZipkinTestUtil.PARENT_SPAN_ID; | ||
import static io.opentelemetry.exporter.zipkin.ZipkinTestUtil.SPAN_ID; | ||
import static io.opentelemetry.exporter.zipkin.ZipkinTestUtil.TRACE_ID; | ||
import static org.assertj.core.api.Assertions.assertThat; | ||
|
||
import org.junit.jupiter.api.Test; | ||
import zipkin2.Endpoint; | ||
import zipkin2.Span; | ||
import zipkin2.reporter.Encoding; | ||
import zipkin2.reporter.SpanBytesEncoder; | ||
|
||
class BytesEncoderAdapterTest { | ||
|
||
/** Contains {@link Span#localEndpoint()} to ensure would be encoded differently. */ | ||
private final Span testSpan = | ||
Span.newBuilder() | ||
.traceId(TRACE_ID) | ||
.parentId(PARENT_SPAN_ID) | ||
.id(SPAN_ID) | ||
.localEndpoint(Endpoint.newBuilder().serviceName("test").build()) | ||
.build(); | ||
|
||
@Test | ||
void testJsonV2() { | ||
BytesEncoderAdapter adapter = new BytesEncoderAdapter(zipkin2.codec.SpanBytesEncoder.JSON_V2); | ||
assertThat(adapter.encoding()).isEqualTo(Encoding.JSON); | ||
assertThat(adapter.encode(testSpan)).isEqualTo(SpanBytesEncoder.JSON_V2.encode(testSpan)); | ||
assertThat(adapter.sizeInBytes(testSpan)) | ||
.isEqualTo(SpanBytesEncoder.JSON_V2.sizeInBytes(testSpan)); | ||
assertThat(adapter).hasToString(SpanBytesEncoder.JSON_V2.toString()); | ||
} | ||
|
||
@Test | ||
void testProtobuf() { | ||
BytesEncoderAdapter adapter = new BytesEncoderAdapter(zipkin2.codec.SpanBytesEncoder.PROTO3); | ||
assertThat(adapter.encoding()).isEqualTo(Encoding.PROTO3); | ||
assertThat(adapter.encode(testSpan)).isEqualTo(SpanBytesEncoder.PROTO3.encode(testSpan)); | ||
assertThat(adapter.sizeInBytes(testSpan)) | ||
.isEqualTo(SpanBytesEncoder.PROTO3.sizeInBytes(testSpan)); | ||
assertThat(adapter).hasToString(SpanBytesEncoder.PROTO3.toString()); | ||
} | ||
|
||
@Test | ||
@SuppressWarnings("deprecation") // we have to use the deprecated thrift encoding to test it | ||
void testThrift() { | ||
BytesEncoderAdapter adapter = new BytesEncoderAdapter(zipkin2.codec.SpanBytesEncoder.THRIFT); | ||
assertThat(adapter.encoding()).isEqualTo(Encoding.THRIFT); | ||
assertThat(adapter.encode(testSpan)).isEqualTo(SpanBytesEncoder.THRIFT.encode(testSpan)); | ||
assertThat(adapter.sizeInBytes(testSpan)) | ||
.isEqualTo(SpanBytesEncoder.THRIFT.sizeInBytes(testSpan)); | ||
assertThat(adapter).hasToString(SpanBytesEncoder.THRIFT.toString()); | ||
} | ||
|
||
@Test | ||
void testJsonV1() { | ||
BytesEncoderAdapter adapter = new BytesEncoderAdapter(zipkin2.codec.SpanBytesEncoder.JSON_V1); | ||
assertThat(adapter.encoding()).isEqualTo(Encoding.JSON); | ||
assertThat(adapter.encode(testSpan)).isEqualTo(SpanBytesEncoder.JSON_V1.encode(testSpan)); | ||
assertThat(adapter.sizeInBytes(testSpan)) | ||
.isEqualTo(SpanBytesEncoder.JSON_V1.sizeInBytes(testSpan)); | ||
assertThat(adapter).hasToString(SpanBytesEncoder.JSON_V1.toString()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this can't be unit tested as the switch is on an enum