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.Span
Create and start ad-hoc custom span with the default name as a child span of the request span (if available).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).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
GlobalTracer
is registered, resource-level span should be stored in theOpenTracingFeature.SPAN_CONTEXT_PROPERTY
. This span is resolved and returned as anOptional
.- Parameters:
context
-ContainerRequestContext
instance, can be obtained via@Context
injection- Returns:
Optional
of 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
-ContainerRequestContext
instance, can be obtained via@Context
injection- 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
-ContainerRequestContext
instance, can be obtained via@Context
injectionspanName
- 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.
-