OpenTracing instrumentation for JAX-RS standard. It supports server and client request tracing.
Instrumentation by default adds set of standard tags and sets span operation name with HTTP method. This can be overridden by span decorators.
DynamicFeature dynamicFeafure = new ServerTracingDynamicFeature.Builder(tracer)
.withDecorators(Arrays.asList(ServerSpanDecorator.HTTP_WILDCARD_PATH_OPERATION_NAME,
ServerSpanDecorator.STANDARD_TAGS))
.build();
// register this in javax.ws.rs.core.Application
@GET
@Path("/hello")
@Traced(operationName = "helloRenamed") // optional, by default operation name is provided by ServerSpanDecorator
public Response hello(@BeanParam ServerSpanContext serverSpanContext) {
/**
* Some business logic
*/
Span childSpan = tracer.buildSpan("businessOperation")
.asChildOf(serverSpanContext.get())
.start())
childSpan.finish();
return Response.status(Response.Status.OK).build();
}
Client client = ClientBuilder.newClient();
client.register(ClientTracingFeature.class);
Response response = jaxRsClient.target("http://localhost/endpoint")
.request()
.property(TracingProperties.CHILD_OF, parentSpanContext) // optional, by default new trace is started
.property(TracingProperties.TRACING_DISABLED, false) // optional, by default false
.get();
./mvnw clean install
Follow instructions in RELEASE