-
- All Implemented Interfaces:
-
okhttp3.Interceptor
public class DatadogInterceptor extends TracingInterceptor
Provides automatic RUM & APM integration for OkHttpClient by way of the Interceptor system.
For RUM integration: this interceptor will log the request as a RUM Resource, and fill the request information (url, method, status code, optional error). Note that RUM Resources are only tracked when a view is active. You can use one of the existing ViewTrackingStrategy when configuring the SDK (see RumConfiguration.Builder.useViewTrackingStrategy) or start a view manually (see RumMonitor.startView).
For APM integration: 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.
Note: If you want to get more insights on the network requests (such as redirections), you can also add TracingInterceptor 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 client = OkHttpClient.Builder() .addInterceptor(DatadogInterceptor.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 classDatadogInterceptor.BuilderA Builder for the DatadogInterceptor.
-