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,
Tracerand an optional parentSpanContextneeds 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
Tracergets 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
SpanContextis 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
Spanwith operation name generated from HTTP method and resource method and class is created based on the resolvedTracerand 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
targettarget.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 StringCURRENT_SPAN_CONTEXT_PROPERTY_NAMETheSpanContextproperty name.static StringENABLED_PROPERTY_NAMEIf set to false, tracing will be disabled.static StringJAX_RS_TRACING_COMPONENTName of tracing component used to retrieve tracing configuration.static StringSPAN_NAME_PROPERTY_NAMEOverride name of the span created for client call.static StringTRACER_PROPERTY_NAMETheTracerproperty name.static StringX_OT_SPAN_CONTEXTHeader used by Envoy proxy.static StringX_REQUEST_IDHeader 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 voidfilter(ClientRequestContext requestContext)voidfilter(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
TheTracerproperty 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
TheSpanContextproperty 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:
filterin interfaceClientRequestFilter
-
filter
public void filter(ClientRequestContext requestContext, ClientResponseContext responseContext)
- Specified by:
filterin interfaceClientResponseFilter
-
-