-
- All Implemented Interfaces:
-
okhttp3.Interceptor
public class DatadogInterceptor extends TracingInterceptor
Provides automatic integration for OkHttpClient by way of the Interceptor system.
This interceptor will combine the effects of the TracingInterceptor and the RumInterceptor.
From RumInterceptor: 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 Configuration.Builder.useViewTrackingStrategy) or start a view manually (see RumMonitor.startView).
From TracingInterceptor: 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 this interceptor as a Network level interceptor.
To use:
val tracedHosts = listOf("example.com", "example.eu") OkHttpClient client = new OkHttpClient.Builder() .addInterceptor(new DatadogInterceptor(tracedHosts)) // Optionally to get information about redirections and retries // .addNetworkInterceptor(new TracingInterceptor(tracedHosts)) .build();
-
-
Constructor Summary
Constructors Constructor Description DatadogInterceptor(Map<String, Set<TracingHeaderType>> firstPartyHostsWithHeaderType, TracedRequestListener tracedRequestListener, RumResourceAttributesProvider rumResourceAttributesProvider, Float traceSamplingRate)Creates a TracingInterceptor to automatically create a trace around OkHttp Requests, and track RUM Resources. DatadogInterceptor(Map<String, Set<TracingHeaderType>> firstPartyHostsWithHeaderType, TracedRequestListener tracedRequestListener, RumResourceAttributesProvider rumResourceAttributesProvider)Creates a TracingInterceptor to automatically create a trace around OkHttp Requests, and track RUM Resources. DatadogInterceptor(Map<String, Set<TracingHeaderType>> firstPartyHostsWithHeaderType, TracedRequestListener tracedRequestListener)Creates a TracingInterceptor to automatically create a trace around OkHttp Requests, and track RUM Resources. DatadogInterceptor(Map<String, Set<TracingHeaderType>> firstPartyHostsWithHeaderType)Creates a TracingInterceptor to automatically create a trace around OkHttp Requests, and track RUM Resources. DatadogInterceptor(List<String> firstPartyHosts, TracedRequestListener tracedRequestListener, RumResourceAttributesProvider rumResourceAttributesProvider, Float traceSamplingRate)Creates a TracingInterceptor to automatically create a trace around OkHttp Requests, and track RUM Resources. DatadogInterceptor(List<String> firstPartyHosts, TracedRequestListener tracedRequestListener, RumResourceAttributesProvider rumResourceAttributesProvider)Creates a TracingInterceptor to automatically create a trace around OkHttp Requests, and track RUM Resources. DatadogInterceptor(List<String> firstPartyHosts, TracedRequestListener tracedRequestListener)Creates a TracingInterceptor to automatically create a trace around OkHttp Requests, and track RUM Resources. DatadogInterceptor(List<String> firstPartyHosts)Creates a TracingInterceptor to automatically create a trace around OkHttp Requests, and track RUM Resources. DatadogInterceptor(TracedRequestListener tracedRequestListener, RumResourceAttributesProvider rumResourceAttributesProvider, Float traceSamplingRate)Creates a TracingInterceptor to automatically create a trace around OkHttp Requests, and track RUM Resources. DatadogInterceptor(TracedRequestListener tracedRequestListener, RumResourceAttributesProvider rumResourceAttributesProvider)Creates a TracingInterceptor to automatically create a trace around OkHttp Requests, and track RUM Resources. DatadogInterceptor(TracedRequestListener tracedRequestListener)Creates a TracingInterceptor to automatically create a trace around OkHttp Requests, and track RUM Resources. DatadogInterceptor()Creates a TracingInterceptor to automatically create a trace around OkHttp Requests, and track RUM Resources.
-
Method Summary
Modifier and Type Method Description Responseintercept(Interceptor.Chain chain)-
-
Constructor Detail
-
DatadogInterceptor
DatadogInterceptor(Map<String, Set<TracingHeaderType>> firstPartyHostsWithHeaderType, TracedRequestListener tracedRequestListener, RumResourceAttributesProvider rumResourceAttributesProvider, Float traceSamplingRate)
Creates a TracingInterceptor to automatically create a trace around OkHttp Requests, and track RUM Resources.- Parameters:
firstPartyHostsWithHeaderType- the list of all the hosts and header types that you want to be automatically tracked by this interceptor.tracedRequestListener- which listens on the intercepted okhttp3.Request and offers the possibility to modify the created io.opentracing.Span.rumResourceAttributesProvider- which listens on the intercepted okhttp3.Request and offers the possibility to add custom attributes to the RUM resource events.traceSamplingRate- the sampling rate for APM traces created for auto-instrumented requests.
-
DatadogInterceptor
DatadogInterceptor(Map<String, Set<TracingHeaderType>> firstPartyHostsWithHeaderType, TracedRequestListener tracedRequestListener, RumResourceAttributesProvider rumResourceAttributesProvider)
Creates a TracingInterceptor to automatically create a trace around OkHttp Requests, and track RUM Resources.- Parameters:
firstPartyHostsWithHeaderType- the list of all the hosts and header types that you want to be automatically tracked by this interceptor.tracedRequestListener- which listens on the intercepted okhttp3.Request and offers the possibility to modify the created io.opentracing.Span.rumResourceAttributesProvider- which listens on the intercepted okhttp3.Request and offers the possibility to add custom attributes to the RUM resource events.
-
DatadogInterceptor
DatadogInterceptor(Map<String, Set<TracingHeaderType>> firstPartyHostsWithHeaderType, TracedRequestListener tracedRequestListener)
Creates a TracingInterceptor to automatically create a trace around OkHttp Requests, and track RUM Resources.- Parameters:
firstPartyHostsWithHeaderType- the list of all the hosts and header types that you want to be automatically tracked by this interceptor.tracedRequestListener- which listens on the intercepted okhttp3.Request and offers the possibility to modify the created io.opentracing.Span.
-
DatadogInterceptor
DatadogInterceptor(Map<String, Set<TracingHeaderType>> firstPartyHostsWithHeaderType)
Creates a TracingInterceptor to automatically create a trace around OkHttp Requests, and track RUM Resources.- Parameters:
firstPartyHostsWithHeaderType- the list of all the hosts and header types that you want to be automatically tracked by this interceptor.
-
DatadogInterceptor
DatadogInterceptor(List<String> firstPartyHosts, TracedRequestListener tracedRequestListener, RumResourceAttributesProvider rumResourceAttributesProvider, Float traceSamplingRate)
Creates a TracingInterceptor to automatically create a trace around OkHttp Requests, and track RUM Resources.- Parameters:
firstPartyHosts- the list of first party hosts.tracedRequestListener- which listens on the intercepted okhttp3.Request and offers the possibility to modify the created io.opentracing.Span.rumResourceAttributesProvider- which listens on the intercepted okhttp3.Request and offers the possibility to add custom attributes to the RUM resource events.traceSamplingRate- the sampling rate for APM traces created for auto-instrumented requests.
-
DatadogInterceptor
DatadogInterceptor(List<String> firstPartyHosts, TracedRequestListener tracedRequestListener, RumResourceAttributesProvider rumResourceAttributesProvider)
Creates a TracingInterceptor to automatically create a trace around OkHttp Requests, and track RUM Resources.- Parameters:
firstPartyHosts- the list of first party hosts.tracedRequestListener- which listens on the intercepted okhttp3.Request and offers the possibility to modify the created io.opentracing.Span.rumResourceAttributesProvider- which listens on the intercepted okhttp3.Request and offers the possibility to add custom attributes to the RUM resource events.
-
DatadogInterceptor
DatadogInterceptor(List<String> firstPartyHosts, TracedRequestListener tracedRequestListener)
Creates a TracingInterceptor to automatically create a trace around OkHttp Requests, and track RUM Resources.- Parameters:
firstPartyHosts- the list of first party hosts.tracedRequestListener- which listens on the intercepted okhttp3.Request and offers the possibility to modify the created io.opentracing.Span.
-
DatadogInterceptor
DatadogInterceptor(List<String> firstPartyHosts)
Creates a TracingInterceptor to automatically create a trace around OkHttp Requests, and track RUM Resources.- Parameters:
firstPartyHosts- the list of first party hosts.
-
DatadogInterceptor
DatadogInterceptor(TracedRequestListener tracedRequestListener, RumResourceAttributesProvider rumResourceAttributesProvider, Float traceSamplingRate)
Creates a TracingInterceptor to automatically create a trace around OkHttp Requests, and track RUM Resources.- Parameters:
tracedRequestListener- which listens on the intercepted okhttp3.Request and offers the possibility to modify the created io.opentracing.Span.rumResourceAttributesProvider- which listens on the intercepted okhttp3.Request and offers the possibility to add custom attributes to the RUM resource events.traceSamplingRate- the sampling rate for APM traces created for auto-instrumented requests.
-
DatadogInterceptor
DatadogInterceptor(TracedRequestListener tracedRequestListener, RumResourceAttributesProvider rumResourceAttributesProvider)
Creates a TracingInterceptor to automatically create a trace around OkHttp Requests, and track RUM Resources.- Parameters:
tracedRequestListener- which listens on the intercepted okhttp3.Request and offers the possibility to modify the created io.opentracing.Span.rumResourceAttributesProvider- which listens on the intercepted okhttp3.Request and offers the possibility to add custom attributes to the RUM resource events.
-
DatadogInterceptor
DatadogInterceptor(TracedRequestListener tracedRequestListener)
Creates a TracingInterceptor to automatically create a trace around OkHttp Requests, and track RUM Resources.- Parameters:
tracedRequestListener- which listens on the intercepted okhttp3.Request and offers the possibility to modify the created io.opentracing.Span.
-
DatadogInterceptor
DatadogInterceptor()
Creates a TracingInterceptor to automatically create a trace around OkHttp Requests, and track RUM Resources.
-
-
Method Detail
-
intercept
Response intercept(Interceptor.Chain chain)
-
-
-
-