Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 4 additions & 16 deletions dd-java-agent/instrumentation/rxjava/rxjava-3.0/build.gradle
Original file line number Diff line number Diff line change
@@ -1,36 +1,24 @@

muzzle {
pass {
group = "io.reactivex.rxjava3"
module = "rxjava"
versions = "[3.0.0,)"
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 muzzle fail block removed — no CI check that rxjava3 advice doesn't match rxjava2 artifacts

Removes the build-time safety net preventing rxjava3 instrumentation from being applied to rxjava2 classes; namespace-separation bugs can silently reach production.

Assertion details
  • Input: A future change accidentally broadens type constraints in a rxjava3 Advice class, making it match io.reactivex.rxjava2.* types
  • Expected: CI muzzle task fails with 'rxjava2-must-not-match' assertion, blocking the merge
  • Actual: Without the fail block, muzzle only checks the pass case. The namespace-separation constraint is undocumented and unverified; the accidental match would reach production undetected.

Was this helpful? React 👍 or 👎
🤖 Datadog Autotest · What is Autotest? · Any feedback? Reach out in #autotest

// Assert the rxjava3 advice never resolves against rxjava2 — the two namespaces
// must not overlap. rxjava3 references io.reactivex.rxjava3.core.*, absent from the
// rxjava2 artifact, so muzzle must fail to match it.
fail {
name = "rxjava2-must-not-match"
group = "io.reactivex.rxjava2"
module = "rxjava"
versions = "[2.0.0,)"
}
}

apply from: "$rootDir/gradle/java.gradle"

addTestSuiteForDir('latestDepTest', 'test')

dependencies {
compileOnly group: 'org.reactivestreams', name: 'reactive-streams', version: '1.0.3'
compileOnly group: 'org.reactivestreams', name: 'reactive-streams', version: '1.0.0'
compileOnly group: 'io.reactivex.rxjava3', name: 'rxjava', version: '3.0.0'

testImplementation project(':dd-java-agent:instrumentation:datadog:tracing:trace-annotation')
testImplementation project(':dd-java-agent:instrumentation:opentelemetry:opentelemetry-annotations-1.20')

testImplementation group: 'io.reactivex.rxjava3', name: 'rxjava', version: '3.0.0'
testImplementation group: 'io.opentelemetry.instrumentation', name: 'opentelemetry-instrumentation-annotations', version: '1.28.0'

// Load the rxjava2 instrumenter at test runtime to prove the two versions coexist on
// the agent without interference (it stays dormant with only rxjava3 on the classpath).
testRuntimeOnly project(':dd-java-agent:instrumentation:rxjava:rxjava-2.0')

latestDepTestImplementation group: 'io.reactivex.rxjava3', name: 'rxjava', version: '+'
latestDepTestImplementation group: 'io.reactivex.rxjava3', name: 'rxjava', version: '3.+'
}
134 changes: 0 additions & 134 deletions dd-java-agent/instrumentation/rxjava/rxjava-3.0/gradle.lockfile

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@

public final class CompletableInstrumentation
implements Instrumenter.ForSingleType, Instrumenter.HasMethodAdvice {

@Override
public String instrumentedType() {
return "io.reactivex.rxjava3.core.Completable";
Expand Down Expand Up @@ -55,6 +54,7 @@ public static ContextScope onSubscribe(
Context parentContext =
InstrumentationContext.get(Completable.class, Context.class).get(completable);
if (parentContext != null) {
// wrap the observer so spans from its events treat the captured span as their parent
observer = new TracingCompletableObserver(observer, parentContext);
// attach the context here in case additional observers are created during subscribe
return parentContext.attach();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@

public final class FlowableInstrumentation
implements Instrumenter.ForSingleType, Instrumenter.HasMethodAdvice {

@Override
public String instrumentedType() {
return "io.reactivex.rxjava3.core.Flowable";
Expand Down Expand Up @@ -54,6 +53,7 @@ public static ContextScope onSubscribe(
Context parentContext =
InstrumentationContext.get(Flowable.class, Context.class).get(flowable);
if (parentContext != null) {
// wrap the subscriber so spans from its events treat the captured span as their parent
subscriber = new TracingSubscriber<>(subscriber, parentContext);
// attach the context here in case additional subscribers are created during subscribe
return parentContext.attach();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ public static ContextScope onSubscribe(
if (observer != null) {
Context parentContext = InstrumentationContext.get(Maybe.class, Context.class).get(maybe);
if (parentContext != null) {
// wrap the observer so spans from its events treat the captured span as their parent
observer = new TracingMaybeObserver<>(observer, parentContext);
// attach the context here in case additional observers are created during subscribe
return parentContext.attach();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ public static ContextScope onSubscribe(
Context parentContext =
InstrumentationContext.get(Observable.class, Context.class).get(observable);
if (parentContext != null) {
// wrap the observer so spans from its events treat the captured span as their parent
observer = new TracingObserver<>(observer, parentContext);
// attach the context here in case additional observers are created during subscribe
return parentContext.attach();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,40 +13,39 @@
@AutoService(InstrumenterModule.class)
public final class RxJavaModule extends InstrumenterModule.ContextTracking {
public RxJavaModule() {
super("rxjava", "rxjava-3");
super("rxjava");

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Restore the rxjava-3 integration alias

With only super("rxjava"), this module's integration-name list no longer includes rxjava-3, and InstrumenterConfig.isIntegrationEnabled(...) only checks the names supplied by the module. In deployments that use the version-specific opt-out, e.g. DD_TRACE_RXJAVA_3_ENABLED=false, RxJava 3 instrumentation will now remain enabled unless all RxJava instrumentation is disabled via the shared rxjava name, which is a customer-facing config regression for apps that need to disable only RxJava 3.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 super("rxjava") drops rxjava-3 alias — DD_TRACE_RXJAVA_3_ENABLED=false silently ignored

Any customer who disabled rxjava3 instrumentation with DD_TRACE_RXJAVA_3_ENABLED=false will have it involuntarily re-enabled after upgrading to an agent built from this diff.

Assertion details
  • Input: Customer sets DD_TRACE_RXJAVA_3_ENABLED=false (maps to system property dd.trace.rxjava-3.enabled=false / config key trace.rxjava-3.enabled) to opt out of rxjava3 instrumentation
  • Expected: InstrumenterConfig.isIntegrationEnabled(["rxjava", "rxjava-3"], true) returns false because the AND-loop evaluates trace.rxjava-3.enabled=false → anyEnabled &= false
  • Actual: With super("rxjava") the names list is ["rxjava"] only. The loop never checks trace.rxjava-3.enabled. anyEnabled &= true (rxjava not set) → returns true; the integration stays enabled despite the explicit opt-out.

Was this helpful? React 👍 or 👎
🤖 Datadog Autotest · What is Autotest? · Any feedback? Reach out in #autotest

Suggested change
super("rxjava");
super("rxjava", "rxjava-3");

}

@Override
public String[] helperClassNames() {
return new String[] {
packageName + ".TracingCompletableObserver",
packageName + ".TracingObserver",
packageName + ".TracingSubscriber",
packageName + ".TracingSingleObserver",
packageName + ".TracingMaybeObserver",
packageName + ".TracingObserver",
packageName + ".TracingCompletableObserver",
packageName + ".RxJavaAsyncResultExtension",
packageName + ".TracingSingleObserver",
};
}

@Override
public Map<String, String> contextStore() {
String contextClass = Context.class.getName();
final Map<String, String> store = new HashMap<>();
store.put("io.reactivex.rxjava3.core.Flowable", contextClass);
store.put("io.reactivex.rxjava3.core.Completable", contextClass);
store.put("io.reactivex.rxjava3.core.Maybe", contextClass);
store.put("io.reactivex.rxjava3.core.Observable", contextClass);
store.put("io.reactivex.rxjava3.core.Single", contextClass);
store.put("io.reactivex.rxjava3.core.Observable", Context.class.getName());
store.put("io.reactivex.rxjava3.core.Flowable", Context.class.getName());
store.put("io.reactivex.rxjava3.core.Single", Context.class.getName());
store.put("io.reactivex.rxjava3.core.Maybe", Context.class.getName());
store.put("io.reactivex.rxjava3.core.Completable", Context.class.getName());
return store;
}

@Override
public List<Instrumenter> typeInstrumentations() {
return asList(
new CompletableInstrumentation(),
new ObservableInstrumentation(),
new FlowableInstrumentation(),
new SingleInstrumentation(),
new MaybeInstrumentation(),
new ObservableInstrumentation(),
new SingleInstrumentation());
new CompletableInstrumentation());
}
}
Loading
Loading