Class OpenTelemetryContext

java.lang.Object
org.apache.cxf.tracing.opentelemetry.OpenTelemetryContext
All Implemented Interfaces:
TracerContext

public class OpenTelemetryContext extends Object implements TracerContext
  • Constructor Summary

    Constructors
    Constructor
    Description
    OpenTelemetryContext(io.opentelemetry.api.trace.Tracer tracer)
     
    OpenTelemetryContext(io.opentelemetry.api.trace.Tracer tracer, io.opentelemetry.api.trace.Span continuation)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    annotate(String key, String value)
    Adds a key/value pair to the currently active span.
    <T> T
    continueSpan(Traceable<T> traceable)
    Picks up an currently detached span from another thread.
    io.opentelemetry.context.Scope
    startSpan(String description)
    Starts a new span in the current thread.
    void
    timeline(String message)
    Adds a timeline to the currently active span.
    <T> T
    unwrap(Class<T> clazz)
    Returns an object of the specified type to allow access to the specific API of the tracing provider.
    <T> Callable<T>
    wrap(String description, Traceable<T> traceable)
    Wraps the traceable into a new span, preserving the current span as a parent.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • OpenTelemetryContext

      public OpenTelemetryContext(io.opentelemetry.api.trace.Tracer tracer)
    • OpenTelemetryContext

      public OpenTelemetryContext(io.opentelemetry.api.trace.Tracer tracer, io.opentelemetry.api.trace.Span continuation)
  • Method Details

    • startSpan

      public io.opentelemetry.context.Scope startSpan(String description)
      Description copied from interface: TracerContext
      Starts a new span in the current thread.
      Specified by:
      startSpan in interface TracerContext
      Parameters:
      description - span description
      Returns:
      span instance object
    • continueSpan

      public <T> T continueSpan(Traceable<T> traceable) throws Exception
      Description copied from interface: TracerContext
      Picks up an currently detached span from another thread. This method is intended to be used in the context of JAX-RS asynchronous invocations, where request and response are effectively executed by different threads.
      Specified by:
      continueSpan in interface TracerContext
      Parameters:
      traceable - traceable implementation to be executed
      Returns:
      the result of the execution
      Throws:
      Exception - any exception being thrown by the traceable implementation
    • wrap

      public <T> Callable<T> wrap(String description, Traceable<T> traceable)
      Description copied from interface: TracerContext
      Wraps the traceable into a new span, preserving the current span as a parent.
      Specified by:
      wrap in interface TracerContext
      Parameters:
      description - span description
      traceable - traceable implementation to be wrapped
      Returns:
      callable to be executed (in current thread or any other thread pool)
    • annotate

      public void annotate(String key, String value)
      Description copied from interface: TracerContext
      Adds a key/value pair to the currently active span.
      Specified by:
      annotate in interface TracerContext
      Parameters:
      key - key to add
      value - value to add
    • timeline

      public void timeline(String message)
      Description copied from interface: TracerContext
      Adds a timeline to the currently active span.
      Specified by:
      timeline in interface TracerContext
      Parameters:
      message - timeline message
    • unwrap

      public <T> T unwrap(Class<T> clazz)
      Description copied from interface: TracerContext
      Returns an object of the specified type to allow access to the specific API of the tracing provider.
      Specified by:
      unwrap in interface TracerContext
      Parameters:
      clazz - - the class of the object to be returned.
      Returns:
      an instance of the specified class