Skip to content
Draft
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,)"
}
// 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");
}

@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