OpenTracing Instrumentation for RxJava
Clone or download

README.md

Build Status Coverage Status Released Version

OpenTracing RxJava Instrumentation

OpenTracing instrumentation for RxJava.

Installation

RxJava 1

pom.xml

<dependency>
    <groupId>io.opentracing.contrib</groupId>
    <artifactId>opentracing-rxjava-1</artifactId>
    <version>VERSION</version>
</dependency>

RxJava 2

pom.xml

<dependency>
    <groupId>io.opentracing.contrib</groupId>
    <artifactId>opentracing-rxjava-2</artifactId>
    <version>VERSION</version>
</dependency>

Usage

// Instantiate tracer
Tracer tracer = ...

// Optionally register tracer with GlobalTracer
GlobalTracer.register(tracer);

RxJava 1

// Enable Tracing via TracingRxJavaUtils
TracingRxJavaUtils.enableTracing(tracer);

Subscriber

// Decorate RxJava Subscriber  with TracingSubscriber
Subscriber<Integer> subscriber = ...
Subscriber<Integer> tracingSubscriber = new TracingSubscriber<>(subscriber, "subscriber", tracer);

// Subscribe Observable to TracingSubscriber
observable.subscribe(tracingSubscriber);

Action

// Decorate RxJava Action with TracingActionSubscriber
Action1<Integer> onNext = ...
TracingActionSubscriber<Integer> tracingSubscriber = new TracingActionSubscriber<>(onNext,
        "action", tracer);

// Subscribe Observable to TracingActionSubscriber
observable.subscribe(tracingSubscriber);

Observer

// Decorate RxJava Observer with TracingObserverSubscriber
Observer<Integer> observer = ...
TracingObserverSubscriber<Integer> tracingSubscriber = new TracingObserverSubscriber(observer, 
        "observer", tracer);

//  Subscribe Observable to TracingObserverSubscriber
observable.subscribe(tracingSubscriber);

RxJava 2

// Enable Tracing via TracingRxJava2Utils
TracingRxJava2Utils.enableTracing(tracer);

Observer

// Decorate RxJava Observer with TracingObserver
Observer<Integer> observer = ...
Observer<Integer> tracingObserver = new TracingObserver<>(observer, "observer", tracer);

// Subscribe Observable to TracingObserver
observable.subscribe(tracingObserver);

Consumer

// Decorate RxJava Consumer with TracingConsumer
Consumer<Integer> onNext = ...
TracingConsumer<Integer> tracingConsumer = new TracingConsumer(onNext, "consumer", tracer);

// Subscribe Observable to TracingConsumer
observable.subscribe(tracingConsumer);

License

Apache 2.0 License.