-
Notifications
You must be signed in to change notification settings - Fork 985
Add experimental JdkHttpSender #5557
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
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
80b16dc
Add experimental JdkHttpSender
jack-berg 9c95d65
Disable java 11 tests when running java 8
jack-berg 2955a2c
PR feedback
jack-berg fe93382
Break out method to resolve HttpSenderProvider
jack-berg 818d69f
Merge branch 'main' of https://github.com/open-telemetry/opentelemetr…
jack-berg 2047c5d
Merge branch 'main' of https://github.com/open-telemetry/opentelemetr…
jack-berg ad28caf
fix build
jack-berg 666cf94
Merge branch 'main' of https://github.com/open-telemetry/opentelemetr…
jack-berg 06ff288
Fix build, adjust method order
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
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
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
74 changes: 74 additions & 0 deletions
74
...testHttpSenderProvider/java/io/opentelemetry/exporter/internal/http/HttpExporterTest.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,74 @@ | ||
| /* | ||
| * Copyright The OpenTelemetry Authors | ||
| * SPDX-License-Identifier: Apache-2.0 | ||
| */ | ||
|
|
||
| package io.opentelemetry.exporter.internal.http; | ||
|
|
||
| import static org.assertj.core.api.Assertions.assertThat; | ||
| import static org.assertj.core.api.Assertions.assertThatThrownBy; | ||
|
|
||
| import io.github.netmikey.logunit.api.LogCapturer; | ||
| import io.opentelemetry.exporter.sender.jdk.internal.JdkHttpSender; | ||
| import io.opentelemetry.exporter.sender.okhttp.internal.OkHttpHttpSender; | ||
| import org.assertj.core.api.Assertions; | ||
| import org.junit.jupiter.api.Test; | ||
| import org.junit.jupiter.api.extension.RegisterExtension; | ||
| import org.junitpioneer.jupiter.SetSystemProperty; | ||
|
|
||
| class HttpExporterTest { | ||
|
|
||
| @RegisterExtension | ||
| LogCapturer logCapturer = | ||
| LogCapturer.create().captureForLogger(HttpExporterBuilder.class.getName()); | ||
|
|
||
| @Test | ||
| void build_multipleSendersNoConfiguration() { | ||
| Assertions.assertThatCode( | ||
| () -> new HttpExporterBuilder<>("exporter", "type", "http://localhost").build()) | ||
| .doesNotThrowAnyException(); | ||
|
|
||
| logCapturer.assertContains( | ||
| "Multiple HttpSenderProvider found. Please include only one, " | ||
| + "or specify preference setting io.opentelemetry.exporter.internal.http.HttpSenderProvider " | ||
| + "to the FQCN of the preferred provider."); | ||
| } | ||
|
|
||
| @Test | ||
| @SetSystemProperty( | ||
| key = "io.opentelemetry.exporter.internal.http.HttpSenderProvider", | ||
| value = "io.opentelemetry.exporter.sender.jdk.internal.JdkHttpSenderProvider") | ||
| void build_multipleSendersWithJdk() { | ||
| assertThat(new HttpExporterBuilder<>("exporter", "type", "http://localhost").build()) | ||
| .extracting("httpSender") | ||
| .isInstanceOf(JdkHttpSender.class); | ||
|
|
||
| assertThat(logCapturer.getEvents()).isEmpty(); | ||
| } | ||
|
|
||
| @Test | ||
| @SetSystemProperty( | ||
| key = "io.opentelemetry.exporter.internal.http.HttpSenderProvider", | ||
| value = "io.opentelemetry.exporter.sender.okhttp.internal.OkHttpHttpSenderProvider") | ||
| void build_multipleSendersWithOkHttp() { | ||
| assertThat(new HttpExporterBuilder<>("exporter", "type", "http://localhost").build()) | ||
| .extracting("httpSender") | ||
| .isInstanceOf(OkHttpHttpSender.class); | ||
|
|
||
| assertThat(logCapturer.getEvents()).isEmpty(); | ||
| } | ||
|
|
||
| @Test | ||
| @SetSystemProperty( | ||
| key = "io.opentelemetry.exporter.internal.http.HttpSenderProvider", | ||
| value = "foo") | ||
| void build_multipleSendersNoMatch() { | ||
| assertThatThrownBy( | ||
| () -> new HttpExporterBuilder<>("exporter", "type", "http://localhost").build()) | ||
| .isInstanceOf(IllegalStateException.class) | ||
| .hasMessage( | ||
| "No HttpSenderProvider matched configured io.opentelemetry.exporter.internal.http.HttpSenderProvider: foo"); | ||
|
|
||
| assertThat(logCapturer.getEvents()).isEmpty(); | ||
| } | ||
| } |
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
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.