wongnai / java-apache-httpclient

OpenTracing Apache HttpClient instrumentation

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Build Status Released Version

OpenTracing Apache HttpClient

Apache HttpClient instrumentation.

Configuration

GlogalTracer.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

About

OpenTracing Apache HttpClient instrumentation

License:Apache License 2.0


Languages

Language:Java 63.8%Language:Shell 24.8%Language:Batchfile 11.4%