-
Notifications
You must be signed in to change notification settings - Fork 1k
Unify compression configuration for exporters #4775
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
Merged
jack-berg
merged 6 commits into
open-telemetry:main
from
Donnerbart:1652-unify-compression-configuration
Nov 1, 2022
Merged
Changes from 5 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
65297f9
Fix handling of compressionMethod `none` in GrpcExporterBuilder
Donnerbart f30b833
Fix handling of compressionMethod `none` in OkHttpExporterBuilder
Donnerbart 88f114c
Add compression configuration assertions to AbstractGrpcTelemetryExpo…
Donnerbart d5ec773
Add compression configuration to JaegerGrpcSpanExporterBuilder
Donnerbart c46b177
Add compression configuration to ZipkinSpanExporterBuilder
Donnerbart 1457bee
Specify that zipkin default compression is gzip
jack-berg 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
4 changes: 3 additions & 1 deletion
4
docs/apidiffs/current_vs_latest/opentelemetry-exporter-jaeger.txt
This file contains hidden or 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,4 @@ | ||
| Comparing source compatibility of against | ||
| No changes. | ||
| *** MODIFIED CLASS: PUBLIC FINAL io.opentelemetry.exporter.jaeger.JaegerGrpcSpanExporterBuilder (not serializable) | ||
| === CLASS FILE FORMAT VERSION: 52.0 <- 52.0 | ||
| +++ NEW METHOD: PUBLIC(+) io.opentelemetry.exporter.jaeger.JaegerGrpcSpanExporterBuilder setCompression(java.lang.String) |
4 changes: 3 additions & 1 deletion
4
docs/apidiffs/current_vs_latest/opentelemetry-exporter-zipkin.txt
This file contains hidden or 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,4 @@ | ||
| 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 | ||
| +++ NEW METHOD: PUBLIC(+) io.opentelemetry.exporter.zipkin.ZipkinSpanExporterBuilder setCompression(java.lang.String) |
This file contains hidden or 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 hidden or 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
183 changes: 183 additions & 0 deletions
183
...common/src/test/java/io/opentelemetry/exporter/internal/grpc/GrpcExporterBuilderTest.java
This file contains hidden or 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,183 @@ | ||
| /* | ||
| * Copyright The OpenTelemetry Authors | ||
| * SPDX-License-Identifier: Apache-2.0 | ||
| */ | ||
|
|
||
| package io.opentelemetry.exporter.internal.grpc; | ||
|
|
||
| import static org.assertj.core.api.Assertions.assertThat; | ||
| import static org.mockito.Mockito.mock; | ||
| import static org.mockito.Mockito.when; | ||
|
|
||
| import com.google.common.util.concurrent.Futures; | ||
| import com.google.common.util.concurrent.ListenableFuture; | ||
| import io.grpc.CallOptions; | ||
| import io.grpc.Channel; | ||
| import io.grpc.Codec; | ||
| import io.grpc.ManagedChannel; | ||
| import io.opentelemetry.exporter.internal.marshal.Marshaler; | ||
| import java.net.URI; | ||
| import java.util.function.BiFunction; | ||
| import java.util.function.Supplier; | ||
| import org.junit.jupiter.api.BeforeEach; | ||
| import org.junit.jupiter.api.Test; | ||
|
|
||
| class GrpcExporterBuilderTest { | ||
|
|
||
| private final ManagedChannel channel = mock(ManagedChannel.class); | ||
|
|
||
| private GrpcExporterBuilder<Marshaler> builder; | ||
|
|
||
| @BeforeEach | ||
| @SuppressWarnings("unchecked") | ||
| void setUp() { | ||
| Supplier<BiFunction<Channel, String, MarshalerServiceStub<Marshaler, ?, ?>>> grpcStubFactory = | ||
| mock(Supplier.class); | ||
| when(grpcStubFactory.get()) | ||
| .thenReturn((c, s) -> new TestMarshalerServiceStub(c, CallOptions.DEFAULT)); | ||
|
|
||
| builder = | ||
| GrpcExporter.builder( | ||
| "otlp", "span", 0, URI.create("http://localhost:4317"), grpcStubFactory, "/test"); | ||
| } | ||
|
|
||
| @Test | ||
| void compressionDefault() { | ||
| GrpcExporter<Marshaler> exporter = builder.build(); | ||
| try { | ||
| assertThat(exporter) | ||
| .isInstanceOfSatisfying( | ||
| OkHttpGrpcExporter.class, | ||
| otlp -> assertThat(otlp).extracting("compressionEnabled").isEqualTo(false)); | ||
| } finally { | ||
| exporter.shutdown(); | ||
| } | ||
| } | ||
|
|
||
| @Test | ||
| void compressionNone() { | ||
| GrpcExporter<Marshaler> exporter = builder.setCompression("none").build(); | ||
| try { | ||
| assertThat(exporter) | ||
| .isInstanceOfSatisfying( | ||
| OkHttpGrpcExporter.class, | ||
| otlp -> assertThat(otlp).extracting("compressionEnabled").isEqualTo(false)); | ||
| } finally { | ||
| exporter.shutdown(); | ||
| } | ||
| } | ||
|
|
||
| @Test | ||
| void compressionGzip() { | ||
| GrpcExporter<Marshaler> exporter = builder.setCompression("gzip").build(); | ||
| try { | ||
| assertThat(exporter) | ||
| .isInstanceOfSatisfying( | ||
| OkHttpGrpcExporter.class, | ||
| otlp -> assertThat(otlp).extracting("compressionEnabled").isEqualTo(true)); | ||
| } finally { | ||
| exporter.shutdown(); | ||
| } | ||
| } | ||
|
|
||
| @Test | ||
| void compressionEnabledAndDisabled() { | ||
| GrpcExporter<Marshaler> exporter = | ||
| builder.setCompression("gzip").setCompression("none").build(); | ||
| try { | ||
| assertThat(exporter) | ||
| .isInstanceOfSatisfying( | ||
| OkHttpGrpcExporter.class, | ||
| otlp -> assertThat(otlp).extracting("compressionEnabled").isEqualTo(false)); | ||
| } finally { | ||
| exporter.shutdown(); | ||
| } | ||
| } | ||
|
|
||
| @Test | ||
| void compressionDefaultWithChannel() { | ||
| GrpcExporter<Marshaler> exporter = builder.setChannel(channel).build(); | ||
| try { | ||
| assertThat(exporter) | ||
| .isInstanceOfSatisfying( | ||
| UpstreamGrpcExporter.class, | ||
| otlp -> | ||
| assertThat(otlp) | ||
| .extracting("stub") | ||
| .extracting("callOptions.compressorName") | ||
| .isEqualTo(Codec.Identity.NONE.getMessageEncoding())); | ||
| } finally { | ||
| exporter.shutdown(); | ||
| } | ||
| } | ||
|
|
||
| @Test | ||
| void compressionNoneWithChannel() { | ||
| GrpcExporter<Marshaler> exporter = builder.setChannel(channel).setCompression("none").build(); | ||
| try { | ||
| assertThat(exporter) | ||
| .isInstanceOfSatisfying( | ||
| UpstreamGrpcExporter.class, | ||
| otlp -> | ||
| assertThat(otlp) | ||
| .extracting("stub") | ||
| .extracting("callOptions.compressorName") | ||
| .isEqualTo(Codec.Identity.NONE.getMessageEncoding())); | ||
| } finally { | ||
| exporter.shutdown(); | ||
| } | ||
| } | ||
|
|
||
| @Test | ||
| void compressionGzipWithChannel() { | ||
| GrpcExporter<Marshaler> exporter = builder.setChannel(channel).setCompression("gzip").build(); | ||
| try { | ||
| assertThat(exporter) | ||
| .isInstanceOfSatisfying( | ||
| UpstreamGrpcExporter.class, | ||
| otlp -> | ||
| assertThat(otlp) | ||
| .extracting("stub") | ||
| .extracting("callOptions.compressorName") | ||
| .isEqualTo(new Codec.Gzip().getMessageEncoding())); | ||
| } finally { | ||
| exporter.shutdown(); | ||
| } | ||
| } | ||
|
|
||
| @Test | ||
| void compressionEnabledAndDisabledWithChannel() { | ||
| GrpcExporter<Marshaler> exporter = | ||
| builder.setChannel(channel).setCompression("gzip").setCompression("none").build(); | ||
| try { | ||
| assertThat(exporter) | ||
| .isInstanceOfSatisfying( | ||
| UpstreamGrpcExporter.class, | ||
| otlp -> | ||
| assertThat(otlp) | ||
| .extracting("stub") | ||
| .extracting("callOptions.compressorName") | ||
| .isEqualTo(Codec.Identity.NONE.getMessageEncoding())); | ||
| } finally { | ||
| exporter.shutdown(); | ||
| } | ||
| } | ||
|
|
||
| private final class TestMarshalerServiceStub | ||
| extends MarshalerServiceStub<Marshaler, Void, TestMarshalerServiceStub> { | ||
|
|
||
| private TestMarshalerServiceStub(Channel channel, CallOptions callOptions) { | ||
| super(channel, callOptions); | ||
| } | ||
|
|
||
| @Override | ||
| protected TestMarshalerServiceStub build(Channel channel, CallOptions callOptions) { | ||
| return new TestMarshalerServiceStub(channel, callOptions); | ||
| } | ||
|
|
||
| @Override | ||
| public ListenableFuture<Void> export(Marshaler request) { | ||
| return Futures.immediateVoidFuture(); | ||
| } | ||
| } | ||
| } |
70 changes: 70 additions & 0 deletions
70
...on/src/test/java/io/opentelemetry/exporter/internal/okhttp/OkHttpExporterBuilderTest.java
This file contains hidden or 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.internal.okhttp; | ||
|
|
||
| import static org.assertj.core.api.Assertions.assertThat; | ||
|
|
||
| import io.opentelemetry.exporter.internal.marshal.Marshaler; | ||
| import org.junit.jupiter.api.Test; | ||
|
|
||
| class OkHttpExporterBuilderTest { | ||
|
|
||
| private final OkHttpExporterBuilder<Marshaler> builder = | ||
| new OkHttpExporterBuilder<>("otlp", "span", "http://localhost:4318/v1/traces"); | ||
|
|
||
| @Test | ||
| void compressionDefault() { | ||
| OkHttpExporter<Marshaler> exporter = builder.build(); | ||
| try { | ||
| assertThat(exporter) | ||
| .isInstanceOfSatisfying( | ||
| OkHttpExporter.class, | ||
| otlp -> assertThat(otlp).extracting("compressionEnabled").isEqualTo(false)); | ||
| } finally { | ||
| exporter.shutdown(); | ||
| } | ||
| } | ||
|
|
||
| @Test | ||
| void compressionNone() { | ||
| OkHttpExporter<Marshaler> exporter = builder.setCompression("none").build(); | ||
| try { | ||
| assertThat(exporter) | ||
| .isInstanceOfSatisfying( | ||
| OkHttpExporter.class, | ||
| otlp -> assertThat(otlp).extracting("compressionEnabled").isEqualTo(false)); | ||
| } finally { | ||
| exporter.shutdown(); | ||
| } | ||
| } | ||
|
|
||
| @Test | ||
| void compressionGzip() { | ||
| OkHttpExporter<Marshaler> exporter = builder.setCompression("gzip").build(); | ||
| try { | ||
| assertThat(exporter) | ||
| .isInstanceOfSatisfying( | ||
| OkHttpExporter.class, | ||
| otlp -> assertThat(otlp).extracting("compressionEnabled").isEqualTo(true)); | ||
| } finally { | ||
| exporter.shutdown(); | ||
| } | ||
| } | ||
|
|
||
| @Test | ||
| void compressionEnabledAndDisabled() { | ||
| OkHttpExporter<Marshaler> exporter = | ||
| builder.setCompression("gzip").setCompression("none").build(); | ||
| try { | ||
| assertThat(exporter) | ||
| .isInstanceOfSatisfying( | ||
| OkHttpExporter.class, | ||
| otlp -> assertThat(otlp).extracting("compressionEnabled").isEqualTo(false)); | ||
| } finally { | ||
| exporter.shutdown(); | ||
| } | ||
| } | ||
| } |
This file contains hidden or 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 hidden or 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
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.