Class ClientTracingFilter
- All Implemented Interfaces:
ClientRequestFilter
,ClientResponseFilter
In order to inject the tracing information properly, Tracer
and an optional parent
SpanContext
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
Tracer.global()
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 resolved Tracer
and an optional parent Span
. 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
Modifier and TypeFieldDescriptionstatic final String
TheSpanContext
property name.static final String
If set to false, tracing will be disabled.static final String
Name of tracing component used to retrieve tracing configuration.static final String
Override name of the span created for client call.static final String
TheTracer
property name.static final String
Header used by Envoy proxy.static final String
Header used by routers. -
Constructor Summary
ConstructorDescriptionDefault constructor so this filter can be registered with Jersey as a class. -
Method Summary
Modifier and TypeMethodDescriptionvoid
filter
(ClientRequestContext requestContext) void
filter
(ClientRequestContext requestContext, ClientResponseContext responseContext)
-
Field Details
-
JAX_RS_TRACING_COMPONENT
Name of tracing component used to retrieve tracing configuration.- See Also:
-
TRACER_PROPERTY_NAME
TheTracer
property name.- See Also:
-
SPAN_NAME_PROPERTY_NAME
Override name of the span created for client call. -
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
TheSpanContext
property name.- See Also:
-
X_OT_SPAN_CONTEXT
Header used by Envoy proxy. Automatically propagated when within Jersey and when using helidon-microprofile-tracing module.- See Also:
-
X_REQUEST_ID
Header used by routers. Automatically propagated when within Jersey and when using helidon-microprofile-tracing module.- See Also:
-
-
Constructor Details
-
ClientTracingFilter
public ClientTracingFilter()Default constructor so this filter can be registered with Jersey as a class. Required by integrated platform.
-
-
Method Details
-
filter
- Specified by:
filter
in interfaceClientRequestFilter
-
filter
- Specified by:
filter
in interfaceClientResponseFilter
-