OpenTracing instrumentation for RxJava.
pom.xml
<dependency>
<groupId>io.opentracing.contrib</groupId>
<artifactId>opentracing-rxjava-1</artifactId>
<version>VERSION</version>
</dependency>
pom.xml
<dependency>
<groupId>io.opentracing.contrib</groupId>
<artifactId>opentracing-rxjava-2</artifactId>
<version>VERSION</version>
</dependency>
pom.xml
<dependency>
<groupId>io.opentracing.contrib</groupId>
<artifactId>opentracing-rxjava-3</artifactId>
<version>VERSION</version>
</dependency>
// Instantiate tracer
Tracer tracer = ...
// Optionally register tracer with GlobalTracer
GlobalTracer.register(tracer);
// Enable Tracing via TracingRxJavaUtils
TracingRxJavaUtils.enableTracing(tracer);
// Decorate RxJava Subscriber with TracingSubscriber
Subscriber<Integer> subscriber = ...
Subscriber<Integer> tracingSubscriber = new TracingSubscriber<>(subscriber, "subscriber", tracer);
// Subscribe Observable to TracingSubscriber
observable.subscribe(tracingSubscriber);
// Decorate RxJava Action with TracingActionSubscriber
Action1<Integer> onNext = ...
TracingActionSubscriber<Integer> tracingSubscriber = new TracingActionSubscriber<>(onNext,
"action", tracer);
// Subscribe Observable to TracingActionSubscriber
observable.subscribe(tracingSubscriber);
// Decorate RxJava Observer with TracingObserverSubscriber
Observer<Integer> observer = ...
TracingObserverSubscriber<Integer> tracingSubscriber = new TracingObserverSubscriber(observer,
"observer", tracer);
// Subscribe Observable to TracingObserverSubscriber
observable.subscribe(tracingSubscriber);
// Enable Tracing via TracingRxJava2Utils
// For RxJava 2:
TracingRxJava2Utils.enableTracing(tracer);
// For RxJava 3:
TracingRxJava3Utils.enableTracing(tracer);
// Decorate RxJava Observer with TracingObserver
Observer<Integer> observer = ...
Observer<Integer> tracingObserver = new TracingObserver<>(observer, "observer", tracer);
// Subscribe Observable to TracingObserver
observable.subscribe(tracingObserver);
// Decorate RxJava Consumer with TracingConsumer
Consumer<Integer> onNext = ...
TracingConsumer<Integer> tracingConsumer = new TracingConsumer(onNext, "consumer", tracer);
// Subscribe Observable to TracingConsumer
observable.subscribe(tracingConsumer);