-
- All Implemented Interfaces:
-
okhttp3.Interceptor
public class TracingInterceptor implements InterceptorProvides automatic trace integration for OkHttpClient by way of the Interceptor system.
This interceptor will create a Span around the request and fill the request information (url, method, status code, optional error). It will also propagate the span and trace information in the request header to link it with backend spans.
If you use multiple Interceptors, make sure that this one is called first. If you also want to track network requests as RUM Resources, use the com.datadog.android.okhttp.DatadogInterceptor instead, which combines the RUM and APM integrations.
If you want to get more insights on the network requests (e.g.: redirections), you can also add this interceptor as a Network level interceptor.
To use:
val tracedHostsWithHeaderType = mapOf("example.com" to setOf( TracingHeaderType.DATADOG, TracingHeaderType.TRACECONTEXT), "example.eu" to setOf( TracingHeaderType.DATADOG, TracingHeaderType.TRACECONTEXT)) val okHttpClient = OkHttpClient.Builder() .addInterceptor(TracingInterceptor.Builder(tracedHostsWithHeaderType).build()) // Optionally to get information about redirections and retries // .addNetworkInterceptor(TracingInterceptor.Builder(tracedHostsWithHeaderType).build()) .build()
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description public final classTracingInterceptor.BuilderA Builder class for the TracingInterceptor.
public abstract classTracingInterceptor.BaseBuilderAn abstract Builder class.
-