okhttp3.InterceptorTracingInterceptor from brave-instrumentation-okhttp3@Deprecated
public final class BraveTracingInterceptor
extends java.lang.Object
implements okhttp3.Interceptor
application interceptor and as a network interceptor.
The implementation models the application request as a local span. Each network request will
be a child span. For example, if there's a redirect, there will be one for the application
request and two spans for the associated network requests.
Trace identifiers of each network attempt are propagated to the server via headers prefixed with
`X-B3`. These spans are also reported out of band, with Constants.CLIENT_SEND and
Constants.CLIENT_RECV annotations, binary annotations (tags) like TraceKeys.HTTP_URL and the server's ip and port.
Since this interceptor creates nested spans, you should use nesting-aware
span state like InheritableServerClientAndLocalSpanState. If using
asynchronous calls, you must also wrap the dispatcher's executor
service. Regardless, the interceptor must be registered as both an
application and network interceptor.
Here's how to add tracing to OkHttp:
brave = new Brave.Builder(new InheritableServerClientAndLocalSpanState(localEndpoint))..
// The request dispatcher uses an executor service.. wrap it!
tracePropagatingExecutor = new BraveExecutorService(
new Dispatcher().executorService(),
brave.serverSpanThreadBinder()
);
client = new OkHttpClient.Builder()
.addInterceptor(tracingInterceptor)
.addNetworkInterceptor(tracingInterceptor)
.dispatcher(new Dispatcher(tracePropagatingExecutor));
.build();
| Modifier and Type | Class | Description |
|---|---|---|
static class |
BraveTracingInterceptor.Builder |
Deprecated.
|
| Modifier and Type | Method | Description |
|---|---|---|
static BraveTracingInterceptor.Builder |
builder(com.github.kristofa.brave.Brave brave) |
Deprecated.
Defaults to use
OkHttpParser |
static BraveTracingInterceptor |
create(com.github.kristofa.brave.Brave brave) |
Deprecated.
|
okhttp3.Response |
intercept(okhttp3.Interceptor.Chain chain) |
Deprecated.
|
public static BraveTracingInterceptor create(com.github.kristofa.brave.Brave brave)
public static BraveTracingInterceptor.Builder builder(com.github.kristofa.brave.Brave brave)
OkHttpParserpublic okhttp3.Response intercept(okhttp3.Interceptor.Chain chain)
throws java.io.IOException
intercept in interface okhttp3.Interceptorjava.io.IOExceptionCopyright © 2018 OpenZipkin. All rights reserved.