Class TracingContext


  • public final class TracingContext
    extends Object
    Context for outbound tracing. This is an internal API used from jersey integration with Tracing (currently MP tracing), to share a ThreadLocal instance.

    This class is mutable, to support chains of tracing filters that create additional spans and that need to update the parent span of this context.

    • Method Detail

      • create

        public static TracingContext create​(Tracer tracer,
                                            Map<String,​List<String>> inboundHeaders)
        Create a new tracing context with client tracing enabled.
        Parameters:
        tracer - tracer to use
        inboundHeaders - inbound header to be used for context propagation
        Returns:
        a new tracing context (not associated with current thread)
        See Also:
        parentSpan(SpanContext)
      • create

        public static TracingContext create​(Tracer tracer,
                                            Map<String,​List<String>> inboundHeaders,
                                            boolean clientEnabled)
        Create a new tracing context.
        Parameters:
        tracer - tracer to use
        inboundHeaders - inbound header to be used for context propagation
        clientEnabled - whether client tracing should be enabled or not
        Returns:
        a new tracing context (not associated with current thread)
        See Also:
        parentSpan(SpanContext)
      • traceClient

        public boolean traceClient()
        Whether client (outbound) calls should be traced.
        Returns:
        true if tracing is enabled for client calls
      • parentSpan

        public SpanContext parentSpan()
        Parent span to use for new spans created.
        Returns:
        span context to act as a parent for newly created spans
      • tracer

        public Tracer tracer()
        Tracer to be used when creating new spans.
        Returns:
        tracer to use
      • inboundHeaders

        public Map<String,​List<String>> inboundHeaders()
        Map of headers that were received by server for an inbound call, may be used to propagate additional headers fro outbound request.
        Returns:
        map of inbound headers
      • parentSpan

        public void parentSpan​(SpanContext context)
        Update the parent span - this may be used by filters that inject a new span between to original parent and the outbound call.
        Parameters:
        context - new parent span context