@ClientBinding(configClass=Config.class) @Documented @Retention(RUNTIME) @Target({FIELD,PARAMETER}) public @interface Opentraceable
Client Zipkin integration. The resulting
Client or WebTarget propagates the OpenTracing
context from the ServerRequest to the remote application.
The idea is that
Client needs to have registered OpentracingClientFilter client filterTracer registered as property OpentracingClientFilter.TRACER_PROPERTY_NAME on the client
SpanContext registered as property
OpentracingClientFilter.CURRENT_SPAN_CONTEXT_PROPERTY_NAME
ServerRequest as a property
OpentracingClientFilter.SERVER_REQUEST_PROPERTY_NAME from where the tracing context is injected
// Create the JAX-RS client with registered OpentracingClientFilter:
Client client = ClientBuilder.newClient(new ClientConfig(OpentracingClientFilter.class));
// Provide the tracing context; i.e, 'tracer' and optionally 'parentSpan' to the client call:
Tracer tracer;
Span parentSpan;
Response response = client.target("http://localhost:9080")
.property(OpentracingClientFilter.TRACER_PROPERTY_NAME, tracer)
.property(OpentracingClientFilter.CURRENT_SPAN_PROPERTY_NAME, parentSpan)
.request()
.get();
When using a managed client, the filter gets registered thanks to the Opentraceable annotation:
class MyResource {
@Inject ServerRequest request;
@GET
public String getText(@Uri("http://remote.server.my:9080") @Opentraceable WebTarget target) {
Response response = target.property(OpentracingClientFilter.SERVER_REQUEST_PROPERTY_NAME, request)
.request()
.get();
}
}
OpentracingClientFilterCopyright © 2018, Oracle and/or its affiliates. All Rights Reserved. Use is subject to license terms.