Class TracedResource

java.lang.Object
org.glassfish.jersey.examples.opentracing.TracedResource

@Path("/resource") public class TracedResource extends Object
OpenTracing example resource.

Jersey (with registered OpenTracingFeature will automatically create and start span for each request ("root" span or "request" span) and a child span to be used in the resource method ("resource" span). The root span is used for Jersey-level event logging (resource matching started, request filters applied, etc). The resource span serves for application-level event logging purposes (used-defined). Both are automatically created and also automatically finished.

Resource span is created right before the resource method invocation and finished right after resource method finishes. It can be resolved by calling OpenTracingUtils.getRequestSpan(ContainerRequestContext).

Application code can also create ad-hoc spans as child spans of the resource span. This can be achieved by calling one of the convenience methods OpenTracingUtils.getRequestChildSpan(ContainerRequestContext).

ContainerRequestContext can be obtained via injection.

All the ad-hoc created spans MUST be finished explicitly.

Author:
Adam Lindenthal