-
Notifications
You must be signed in to change notification settings - Fork 851
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update dependency io.zipkin.reporter2:zipkin-reporter-bom to 3.1.1 (#…
…6129) Signed-off-by: Adrian Cole <[email protected]>
- Loading branch information
1 parent
0641844
commit 208118a
Showing
8 changed files
with
189 additions
and
15 deletions.
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()); | ||
} | ||
} | ||
|
||
@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