Add RxJava 3 instrumentation#11506
Draft
amarziali wants to merge 10 commits into
Draft
Conversation
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…izer RxJava 3 introduced io.reactivex.rxjava3.internal.schedulers.AbstractDirectTask, whose static initializer constructs FINISHED/DISPOSED sentinel FutureTask instances. When that initializer first runs under an active trace (e.g. the first delay/timeout scheduler hop inside a span), the executor instrumentation captures a ScopeContinuation on those static singletons that is never cancelled, leaking the pending trace so it is never reported. Disable async propagation while AbstractDirectTask's type initializer runs, mirroring the existing reactor.core.scheduler.SchedulerTask/WorkerTask handling. The matcher is inert unless RxJava 3 is on the classpath. RxJava 2 has no equivalent class. Restores the delayed-Maybe coverage in RxJava3Test, which fails without this fix and passes with it. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…ava3 Two tests were under datadog.trace.instrumentation.rxjava3 while the @Trace-using tests must live under testdog.* (the agent ignores datadog.* for instrumentation). Move all four tests to testdog.* for consistency. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
What Does This Do
We already trace RxJava 1 and 2 but not 3. RxJava 3 moved its types to the
io.reactivex.rxjava3.core.*namespace, so the existing rxjava-2.0 instrumentation never matches it. This adds a newrxjava-3.0module that brings RxJava 3 to parity.What's in it:
dd-java-agent/instrumentation/rxjava/rxjava-3.0module. It ports the rxjava-2.0 logic to the RxJava 3 namespace: context capture on the five reactive types (Flowable, Observable, Single, Maybe, Completable) and re-attachment around subscriber callbacks, plus the async result extension that finishes@WithSpan/@Tracespans when the stream completes, errors, or is cancelled.passfor rxjava3[3.0.0,)and afailblock that asserts the advice can never match the rxjava2 artifact, so the two versions stay isolated. The module also pulls in rxjava-2.0 as a test runtime dependency to confirm both instrumenters coexist.@WithSpanresult extension across all five types, and a Java 8 interop check (fromCompletionStage,fromStream,fromOptional). latestDepTest runs the same suite against the newest published rxjava3.One thing reviewers should look at closely: this also touches the shared
java-concurrentmodule. While testing delayed chains I found that RxJava 3 addedio.reactivex.rxjava3.internal.schedulers.AbstractDirectTask, whose static initializer builds two sentinelFutureTaskinstances. When that initializer first runs under an active trace (the firstdelayortimeouthop inside a span), the executor instrumentation captures a continuation on those static singletons that never gets cancelled, so the trace stays pending and is never reported. RxJava 2 has no equivalent class, which is why the byte for byte equivalent rxjava-2.0 code never hit this. The fix disables async propagation while that type initializer runs, following the same pattern already used for Reactor'sSchedulerTaskandWorkerTask. The matcher is an exact class name, so it stays inert unless RxJava 3 is on the classpath.The Java 8 interop check found no propagation gaps once that fix was in place.
Motivation
Additional Notes
Contributor Checklist
type:and (comp:orinst:) labels in addition to any other useful labelsclose,fix, or any linking keywords when referencing an issueUse
solvesinstead, and assign the PR milestone to the issue/merge. You can also:/merge --commit-message "..."/merge -c/merge -f --reason "reason"; please use this judiciously, as some checks do not run at the PR-levelJira ticket: [PROJ-IDENT]