Class PropagationHelper

  • All Implemented Interfaces:
    io.opentelemetry.context.Scope, AutoCloseable

    public class PropagationHelper
    extends Object
    implements io.opentelemetry.context.Scope
    Helper for the most usual propagation scenarios.
    • Method Detail

      • start

        public static PropagationHelper start​(io.opentelemetry.api.trace.Span span,
                                              io.opentelemetry.context.Context spanContext)
        The most usual constellation where we wrap context and span execution synchronously. Span and Context gets installed and then finished upon closing of returned PropagationHelper, as well as Span gets ended with OK status at the end.
        Parameters:
        span -
        spanContext -
        Returns:
      • startMultiThreaded

        public static PropagationHelper startMultiThreaded​(io.opentelemetry.api.trace.Span span,
                                                           io.opentelemetry.context.Context spanContext)
        Start initial processing of a request that will continue processing in multiple threads. Span and Context gets
        Parameters:
        span -
        spanContext -
        Returns:
      • localScope

        public io.opentelemetry.context.Scope localScope()
        Install span and context as current for partial execution. Span is not finished upon closing this scope and it needs to be ended explicitly via end() method.
        Returns:
        Scope to use in try-with-resources
      • span

        public io.opentelemetry.api.trace.Span span()
      • end

        public void end()
        End the span successfully. Should not be used in single-threaded scenario.
      • end

        public void end​(Throwable error)
        End the span with an error. Can be used in both single and multi-threaded scenarios. Ending span twice in single threaded scenario is prevented.
        Parameters:
        error -
      • close

        public void close()
        Specified by:
        close in interface AutoCloseable
        Specified by:
        close in interface io.opentelemetry.context.Scope