Skip to content

Latest commit

 

History

History
58 lines (46 loc) · 1.97 KB

README.md

File metadata and controls

58 lines (46 loc) · 1.97 KB

Build Status Released Version

OpenTracing JAX-RS Instrumentation

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.

Tracing Server Requests

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();
}

Tracing Client Requests

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();

Development

./mvnw clean install

Release

Follow instructions in RELEASE