-
Notifications
You must be signed in to change notification settings - Fork 333
Migrate OtlpWriterCombinedTest from groovy to junit #11245
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
gh-worker-dd-mergequeue-cf854d
merged 23 commits into
master
from
mtoff/junit-otlp-test
Apr 30, 2026
Merged
Changes from all commits
Commits
Show all changes
23 commits
Select commit
Hold shift + click to select a range
145f884
Introduce isTraceOtlpExporterEnabled branching logic for Sampler.java…
mtoffl01 d183f39
Include regression test for UNSET spans in otlp mode
mtoffl01 d69e491
Create new OTLP writer type, enabled by default when OTEL_TRACES_EXPO…
mtoffl01 e7e3a95
Implement OtlpPayloadDispatcher.java
mtoffl01 af97659
Introduce OtlpPayloadDispatcherTest.java
mtoffl01 015e272
Implement OtlpWriter
mtoffl01 8194971
Introduce OtlpWriterTest.java
mtoffl01 a5cd8fe
Introduce OtlpWriterCombinedTest.java with a TODO
mtoffl01 1615566
WriterFactory: Add OTLP branch for OtlpWriter; include a TODO for a test
mtoffl01 46887fe
nits
mtoffl01 eb2b116
Implement OtlpWriter tests in WriterFactoryTest
mtoffl01 b02aab1
Document problems with OtlpWriterCombinedTest
mtoffl01 594b4b8
fill NPE on writeSpanTag
mtoffl01 491533b
Regression test for UNSET spans in otlp writer mode
mtoffl01 53d53d7
fix grpc path for OtlpWriter and OtlpSender - plus a regression test
mtoffl01 edc1081
Remove OtlpTraceProtoCollector INSTANCE singleton
mtoffl01 5acc0d9
Implement happy path test in OtlpWriterCombinedTest
mtoffl01 2456c8b
Test the OTLP http request body in OtlpHttpRequestBodyTest
mtoffl01 96954d7
Fix NPE on null span type tag, and add regression test
mtoffl01 a09c99e
migrate OtlpWriterCombinedTest to junit
mtoffl01 84687be
Merge branch 'master' into mtoff/junit-otlp-test
mtoffl01 ab734cb
Merge branch 'master' into mtoff/junit-otlp-test
mtoffl01 971d907
remove old groovy file
mtoffl01 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
44 changes: 0 additions & 44 deletions
44
dd-trace-core/src/test/groovy/datadog/trace/common/writer/OtlpWriterCombinedTest.groovy
This file was deleted.
Oops, something went wrong.
56 changes: 56 additions & 0 deletions
56
dd-trace-core/src/test/java/datadog/trace/common/writer/OtlpWriterCombinedTest.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,56 @@ | ||
| package datadog.trace.common.writer; | ||
|
|
||
| import static datadog.trace.api.config.OtlpConfig.TRACE_OTEL_EXPORTER; | ||
| import static datadog.trace.junit.utils.config.WithConfigExtension.injectSysConfig; | ||
| import static org.junit.jupiter.api.Assertions.assertTrue; | ||
|
|
||
| import com.sun.net.httpserver.HttpServer; | ||
| import datadog.trace.core.CoreTracer; | ||
| import datadog.trace.core.DDCoreJavaSpecification; | ||
| import java.io.IOException; | ||
| import java.net.InetSocketAddress; | ||
| import java.util.concurrent.CountDownLatch; | ||
| import java.util.concurrent.TimeUnit; | ||
| import org.junit.jupiter.api.Test; | ||
| import org.junit.jupiter.api.Timeout; | ||
|
|
||
| @Timeout(value = 10, unit = TimeUnit.SECONDS) | ||
| class OtlpWriterCombinedTest extends DDCoreJavaSpecification { | ||
|
|
||
| @Test | ||
| void happyPathOverHttp() throws IOException, InterruptedException { | ||
| injectSysConfig(TRACE_OTEL_EXPORTER, "otlp"); | ||
|
|
||
| CountDownLatch received = new CountDownLatch(1); | ||
| HttpServer server = HttpServer.create(new InetSocketAddress("localhost", 0), 0); | ||
| server.createContext( | ||
| "/v1/traces", | ||
| exchange -> { | ||
| received.countDown(); | ||
| exchange.sendResponseHeaders(200, -1); | ||
| exchange.close(); | ||
| }); | ||
| server.start(); | ||
|
|
||
| OtlpWriter writer = | ||
| OtlpWriter.builder() | ||
| .endpoint( | ||
| "http://" | ||
| + server.getAddress().getHostString() | ||
| + ":" | ||
| + server.getAddress().getPort() | ||
| + "/v1/traces") | ||
| .flushIntervalMilliseconds(-1) | ||
| .build(); | ||
| CoreTracer tracer = tracerBuilder().writer(writer).build(); | ||
| try { | ||
| tracer.buildSpan("test", "fakeOperation").start().finish(); | ||
| writer.flush(); | ||
|
|
||
| assertTrue(received.await(5, TimeUnit.SECONDS), "OTLP server should receive a request"); | ||
| } finally { | ||
| tracer.close(); | ||
| server.stop(0); | ||
| } | ||
| } | ||
| } | ||
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.
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.
you can alternatively annotate the test method like that:
@WithConfig(key = "service", value = "my_service")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.
oh! this is great to know.