Skip to content

opentracing-contrib/java-apache-httpclient

Repository files navigation

Build Status Released Version

OpenTracing Apache HttpClient

Apache HttpClient instrumentation.

Configuration

GlobalTracer.register(tracer);
HttpClient httpClient = new TracingHttpClientBuilder()
    .build();

//custom configuration
HttpClient httpClient = new TracingHttpClientBuilder(
        redirectStrategy, 
        redirectHandlingDisabled,
        GlobalTracer.get(),
        spanDecorators)
    .build();

Linking to parent span

If parent span context is not passed created client spans will be in a new trace.

SpanManager

spanManager.activate(parentSpan); // called in the same thread as client.execute()
client.execute(new HttpGet("url"));

Manually

BasicHttpContext basicHttpContext = new BasicHttpContext();
basicHttpContext.setAttribute(Constants.PARENT_CONTEXT, parentSpan.context());
client.execute(new HttpGet("url"), basicHttpContext);

Development

./mvnw clean install

Release

Follow instructions in RELEASE