Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.mvn/wrapper
src/main/java/io/opentracing/contrib/asynchttpclient
.gitignore
.travis.yml
LICENSE
Makefile
README.md
RELEASE.md
mvnw
mvnw.cmd
pom.xml
settings.xml

README.md

java-asynchttpclient

Build Status OpenTracing Instrumentation for org.asynchttpclient

Requirements

Installation

Releases are hosted on Maven Central.

pom.xml

<dependency>
    <groupId>io.opentracing.contrib.asynchttpclient</groupId>
    <artifactId>asynchttpclient-opentracing</artifactId>
    <version>0.1.0</version>
</dependency>

build.gradle

dependencies {
    compile 'io.opentracing.contrib.asynchttpclient:asynchtpclient-opentracing:0.1.0'
}

Usage

  • Intialize an OpenTracing tracer
  • Create an ActiveSpanSource to return a parent span when a span is created for a request.
  • Create a SpanDecorator or use the DEFAULT implementation.
  • Create a TracingAsyncHttpClient and use it to make requests.
class MyClass {
    final ThreadLocal<Span> activeSpan;

    public MyClass() {
        activeSpan = new ThreadLocal<Span>() {};

        // Source that can extract span data and keep it in a thread-local:
        TracingAsyncHttpClient.ActiveSpanSource activeSpanSource = 
            new TracingAsyncHttpClient.ActiveSpanSource() {
                public Span getActiveSpan() {
                    return activeSpan.get();
                }
            };

        Tracer tracer = ... // Any OpenTracing-compatible tracer.

        AsyncHttpClient client = new TracingAsyncHttpClient(
                    tracer,
                    activeSpanSource,
                    SpanDecorator.DEFAULT
                );
    }
}