Package org.glassfish.jersey.opentracing
Class OpenTracingUtils
java.lang.Object
org.glassfish.jersey.opentracing.OpenTracingUtils
Utility methods for Jersey OpenTracing integration.
- Since:
- 2.26
- Author:
- Adam Lindenthal
-
Method Summary
Modifier and TypeMethodDescriptionstatic io.opentracing.SpanCreate and start ad-hoc custom span with the default name as a child span of the request span (if available).static io.opentracing.SpangetRequestChildSpan(ContainerRequestContext context, String spanName) Create and start ad-hoc custom span with a custom name as a child span of the request span (if available).static Optional<io.opentracing.Span>getRequestSpan(ContainerRequestContext context) Resolve resource-level span.
-
Method Details
-
getRequestSpan
Resolve resource-level span.If open tracing is enabled and
GlobalTraceris registered, resource-level span should be stored in theOpenTracingFeature.SPAN_CONTEXT_PROPERTY. This span is resolved and returned as anOptional.- Parameters:
context-ContainerRequestContextinstance, can be obtained via@Contextinjection- Returns:
Optionalof the resolved span, if found; empty optional if not
-
getRequestChildSpan
Create and start ad-hoc custom span with the default name as a child span of the request span (if available).- Parameters:
context-ContainerRequestContextinstance, can be obtained via@Contextinjection- Returns:
- If parent span ("request span") instance is stored in the
ContainerRequestContext, new span is created as a child span of the found span. If no parent span found, new "root" span is created. In both cases, the returned span is already started. In order to successfully store the tracing,Span.finish()needs to be invoked explicitly, after the traced code finishes.
-
getRequestChildSpan
public static io.opentracing.Span getRequestChildSpan(ContainerRequestContext context, String spanName) Create and start ad-hoc custom span with a custom name as a child span of the request span (if available).- Parameters:
context-ContainerRequestContextinstance, can be obtained via@ContextinjectionspanName- name to be used for the created span- Returns:
- If parent span ("request span") instance is stored in the
ContainerRequestContext, new span is created as a child span of the found span. If no parent span found, new "root" span is created. In both cases, the returned span is already started. In order to successfully store the tracing,Span.finish()needs to be invoked explicitly, after the traced code finishes.
-