-
Notifications
You must be signed in to change notification settings - Fork 344
[reference] reactor-core-3.1 iteration-2 regen against skill-async-iteration-2 #11974
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,167 @@ | ||
| package testdog.trace.instrumentation.reactor.core; | ||
|
|
||
| import static datadog.trace.agent.test.assertions.Matchers.validates; | ||
| import static datadog.trace.agent.test.assertions.SpanMatcher.span; | ||
| import static datadog.trace.agent.test.assertions.TagsMatcher.defaultTags; | ||
| import static datadog.trace.agent.test.assertions.TagsMatcher.error; | ||
| import static datadog.trace.agent.test.assertions.TagsMatcher.tag; | ||
| import static datadog.trace.agent.test.assertions.TraceMatcher.trace; | ||
| import static org.junit.jupiter.api.Assertions.assertEquals; | ||
| import static org.junit.jupiter.api.Assertions.assertThrows; | ||
|
|
||
| import annotatedsample.ReactorTracedMethods; | ||
| import datadog.trace.agent.test.AbstractInstrumentationTest; | ||
| import datadog.trace.agent.test.assertions.SpanMatcher; | ||
| import datadog.trace.agent.test.assertions.TagsMatcher; | ||
| import datadog.trace.bootstrap.instrumentation.api.Tags; | ||
| import datadog.trace.junit.utils.config.WithConfig; | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
After the matcher import is fixed, this class still does not compile because there is no Useful? React with 👍 / 👎. |
||
| import java.util.concurrent.CountDownLatch; | ||
| import org.junit.jupiter.api.Test; | ||
| import reactor.core.publisher.Flux; | ||
| import reactor.core.publisher.Mono; | ||
|
|
||
| @WithConfig(key = "trace.otel.enabled", value = "true") | ||
| class ReactorAsyncResultExtensionTest extends AbstractInstrumentationTest { | ||
|
|
||
| static final String EXCEPTION_MESSAGE = "Test exception"; | ||
|
|
||
| // The COMPONENT and SPAN_KIND tags are stored as UTF8BytesString, so we compare by string content | ||
| // rather than using is("...") which would fail the asymmetric String#equals(UTF8BytesString) | ||
| // check. | ||
| static TagsMatcher otelComponent() { | ||
| return tag(Tags.COMPONENT, validates(o -> "opentelemetry".equals(String.valueOf(o)))); | ||
| } | ||
|
|
||
| static TagsMatcher internalSpanKind() { | ||
| return tag(Tags.SPAN_KIND, validates(o -> Tags.SPAN_KIND_INTERNAL.equals(String.valueOf(o)))); | ||
| } | ||
|
|
||
| // The operation and resource names are stored as UTF8BytesString, so we compare by string content | ||
| // (CharSequence equality is asymmetric: String#equals(UTF8BytesString) is false). | ||
| static SpanMatcher otelSpan(String name) { | ||
| return span() | ||
| .operationName(java.util.regex.Pattern.compile(java.util.regex.Pattern.quote(name))) | ||
| .resourceName((CharSequence cs) -> name.contentEquals(cs)); | ||
| } | ||
|
|
||
| // --- Mono success -------------------------------------------------------- | ||
|
|
||
| @Test | ||
| void withSpanAnnotatedAsyncMono() { | ||
| CountDownLatch latch = new CountDownLatch(1); | ||
| Mono<String> mono = ReactorTracedMethods.traceAsyncMono(latch); | ||
|
|
||
| // The span must not be finished before the async result completes. | ||
| assertEquals(0, writer.size()); | ||
|
|
||
| latch.countDown(); | ||
| mono.block(); | ||
|
|
||
| assertTraces( | ||
| trace( | ||
| otelSpan("ReactorTracedMethods.traceAsyncMono") | ||
| .tags(defaultTags(), otelComponent(), internalSpanKind()))); | ||
| } | ||
|
|
||
| // --- Mono failure -------------------------------------------------------- | ||
|
|
||
| @Test | ||
| void withSpanAnnotatedAsyncFailingMono() { | ||
| CountDownLatch latch = new CountDownLatch(1); | ||
| IllegalStateException expectedException = new IllegalStateException(EXCEPTION_MESSAGE); | ||
| Mono<String> mono = ReactorTracedMethods.traceAsyncFailingMono(latch, expectedException); | ||
|
|
||
| assertEquals(0, writer.size()); | ||
|
|
||
| latch.countDown(); | ||
| assertThrows(IllegalStateException.class, mono::block); | ||
|
|
||
| assertTraces( | ||
| trace( | ||
| otelSpan("ReactorTracedMethods.traceAsyncFailingMono") | ||
| .error() | ||
| .tags( | ||
| defaultTags(), | ||
| otelComponent(), | ||
| internalSpanKind(), | ||
| error(IllegalStateException.class, EXCEPTION_MESSAGE)))); | ||
| } | ||
|
|
||
| // --- Mono cancellation --------------------------------------------------- | ||
|
|
||
| @Test | ||
| void withSpanAnnotatedAsyncCancelledMono() { | ||
| CountDownLatch latch = new CountDownLatch(1); | ||
| Mono<String> mono = ReactorTracedMethods.traceAsyncMono(latch); | ||
|
Comment on lines
+93
to
+95
|
||
|
|
||
| assertEquals(0, writer.size()); | ||
|
|
||
| latch.countDown(); | ||
| mono.subscribe(new ReactorTracedMethods.CancelSubscriber<String>()); | ||
|
|
||
| assertTraces( | ||
| trace( | ||
| otelSpan("ReactorTracedMethods.traceAsyncMono") | ||
| .tags(defaultTags(), otelComponent(), internalSpanKind()))); | ||
|
Comment on lines
+99
to
+105
|
||
| } | ||
|
|
||
| // --- Flux success -------------------------------------------------------- | ||
|
|
||
| @Test | ||
| void withSpanAnnotatedAsyncFlux() { | ||
| CountDownLatch latch = new CountDownLatch(1); | ||
| Flux<String> flux = ReactorTracedMethods.traceAsyncFlux(latch); | ||
|
|
||
| assertEquals(0, writer.size()); | ||
|
|
||
| latch.countDown(); | ||
| flux.blockLast(); | ||
|
|
||
| assertTraces( | ||
| trace( | ||
| otelSpan("ReactorTracedMethods.traceAsyncFlux") | ||
| .tags(defaultTags(), otelComponent(), internalSpanKind()))); | ||
| } | ||
|
|
||
| // --- Flux failure -------------------------------------------------------- | ||
|
|
||
| @Test | ||
| void withSpanAnnotatedAsyncFailingFlux() { | ||
| CountDownLatch latch = new CountDownLatch(1); | ||
| IllegalStateException expectedException = new IllegalStateException(EXCEPTION_MESSAGE); | ||
| Flux<String> flux = ReactorTracedMethods.traceAsyncFailingFlux(latch, expectedException); | ||
|
|
||
| assertEquals(0, writer.size()); | ||
|
|
||
| latch.countDown(); | ||
| assertThrows(IllegalStateException.class, flux::blockLast); | ||
|
|
||
| assertTraces( | ||
| trace( | ||
| otelSpan("ReactorTracedMethods.traceAsyncFailingFlux") | ||
| .error() | ||
| .tags( | ||
| defaultTags(), | ||
| otelComponent(), | ||
| internalSpanKind(), | ||
| error(IllegalStateException.class, EXCEPTION_MESSAGE)))); | ||
| } | ||
|
|
||
| // --- Flux cancellation --------------------------------------------------- | ||
|
|
||
| @Test | ||
| void withSpanAnnotatedAsyncCancelledFlux() { | ||
| CountDownLatch latch = new CountDownLatch(1); | ||
| Flux<String> flux = ReactorTracedMethods.traceAsyncFlux(latch); | ||
|
Comment on lines
+153
to
+155
|
||
|
|
||
| assertEquals(0, writer.size()); | ||
|
|
||
| latch.countDown(); | ||
| flux.subscribe(new ReactorTracedMethods.CancelSubscriber<String>()); | ||
|
|
||
| assertTraces( | ||
| trace( | ||
| otelSpan("ReactorTracedMethods.traceAsyncFlux") | ||
| .tags(defaultTags(), otelComponent(), internalSpanKind()))); | ||
| } | ||
| } | ||
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 static import points at
datadog.trace.agent.test.assertions.Matchers, but that package has noMatchersclass; thevalidateshelper used by the JUnit assertion APIs lives indatadog.trace.test.junit.utils.assertions.Matchers(as used by the sibling RxJava3 JUnit tests). When:dd-java-agent:instrumentation:reactor-core-3.1:compileTestJavacompiles these new tests, javac fails before any Reactor coverage can run.Useful? React with 👍 / 👎.