Class ClientTracingFilter
- java.lang.Object
-
- io.helidon.tracing.jersey.client.ClientTracingFilter
-
- All Implemented Interfaces:
ClientRequestFilter
,ClientResponseFilter
@Priority(750) public class ClientTracingFilter extends Object implements ClientRequestFilter, ClientResponseFilter
This filter adds tracing information the the associated JAX-RS client call based on the provided properties.In order to inject the tracing information properly,
Tracer
and an optional parentSpanContext
needs to be resolved. In case we are in scope of inbound JAX-RS request, the client also uses inbound HTTP headers to determine correct headers for outbound call.The
Tracer
gets resolved in the following order:- From request property
TRACER_PROPERTY_NAME
- From JAX-RS server, when the client is invoked in scope of a JAX-RS inbound request and appropriate filter is configured (see helidon-tracing-jersey and helidon-microprofile-tracing modules)
- From
GlobalTracer.get()
The parent
SpanContext
is resolved as follows- From request property
CURRENT_SPAN_CONTEXT_PROPERTY_NAME
- From JAX-RS server, when the client is invoked in scope of a JAX-rs inbound request
Inbound HTTP headers are resolved from JAX-RS server.
For each client call, a new
Span
with operation name generated from HTTP method and resource method and class is created based on the resolvedTracer
and an optional parentSpan
. The span information is also propagated to the outbound request using HTTP headers injected by tracer.Example 1 - client within a JAX-RS resource (with tracing integration configured on server):
public String someMethod(@Uri(BACKEND) WebTarget target) { Response response = target.request().get(); // process the response }
Example 2 - standalone client (with access to tracer and span), assuming we have a WebTarget ready as
target
target.request() .property(TracingClientFilter.TRACER_PROPERTY_NAME, tracer) .property(TracingClientFilter.CURRENT_SPAN_CONTEXT_PROPERTY_NAME, spanContext) .get();
-
-
Field Summary
Fields Modifier and Type Field Description static String
CURRENT_SPAN_CONTEXT_PROPERTY_NAME
TheSpanContext
property name.static String
ENABLED_PROPERTY_NAME
If set to false, tracing will be disabled.static String
JAX_RS_TRACING_COMPONENT
Name of tracing component used to retrieve tracing configuration.static String
SPAN_NAME_PROPERTY_NAME
Override name of the span created for client call.static String
TRACER_PROPERTY_NAME
TheTracer
property name.static String
X_OT_SPAN_CONTEXT
Header used by Envoy proxy.static String
X_REQUEST_ID
Header used by routers.
-
Constructor Summary
Constructors Constructor Description ClientTracingFilter()
Default constructor so this filter can be registered with Jersey as a class.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
filter(ClientRequestContext requestContext)
void
filter(ClientRequestContext requestContext, ClientResponseContext responseContext)
-
-
-
Field Detail
-
JAX_RS_TRACING_COMPONENT
public static final String JAX_RS_TRACING_COMPONENT
Name of tracing component used to retrieve tracing configuration.- See Also:
- Constant Field Values
-
TRACER_PROPERTY_NAME
public static final String TRACER_PROPERTY_NAME
TheTracer
property name.- See Also:
- Constant Field Values
-
SPAN_NAME_PROPERTY_NAME
public static final String SPAN_NAME_PROPERTY_NAME
Override name of the span created for client call.
-
ENABLED_PROPERTY_NAME
public static final String ENABLED_PROPERTY_NAME
If set to false, tracing will be disabled. If set to true, tracing will depend on overall configuration.
-
CURRENT_SPAN_CONTEXT_PROPERTY_NAME
public static final String CURRENT_SPAN_CONTEXT_PROPERTY_NAME
TheSpanContext
property name.- See Also:
- Constant Field Values
-
X_OT_SPAN_CONTEXT
public static final String X_OT_SPAN_CONTEXT
Header used by Envoy proxy. Automatically propagated when within Jersey and when using helidon-microprofile-tracing module.- See Also:
- Constant Field Values
-
X_REQUEST_ID
public static final String X_REQUEST_ID
Header used by routers. Automatically propagated when within Jersey and when using helidon-microprofile-tracing module.- See Also:
- Constant Field Values
-
-
Method Detail
-
filter
public void filter(ClientRequestContext requestContext)
- Specified by:
filter
in interfaceClientRequestFilter
-
filter
public void filter(ClientRequestContext requestContext, ClientResponseContext responseContext)
- Specified by:
filter
in interfaceClientResponseFilter
-
-