Class ContextPropagationOperator

java.lang.Object
io.opentelemetry.instrumentation.reactor.v3_1.ContextPropagationOperator

public final class ContextPropagationOperator extends Object
Based on Spring Sleuth's Reactor instrumentation.
  • Method Summary

    Modifier and Type
    Method
    Description
     
     
    static io.opentelemetry.context.Context
    getOpenTelemetryContext(reactor.util.context.Context context, io.opentelemetry.context.Context defaultTraceContext)
    Gets Trace Context from Reactor Context.
    static io.opentelemetry.context.Context
    getOpenTelemetryContextFromContextView(reactor.util.context.ContextView contextView, io.opentelemetry.context.Context defaultTraceContext)
    Gets Trace Context from Reactor ContextView.
    void
    Registers a hook that applies to every operator, propagating Context to downstream callbacks to ensure spans in the Context are available throughout the lifetime of a reactive stream.
    void
    Unregisters the hook registered by registerOnEachOperator().
    static <T> reactor.core.publisher.Flux<T>
    runWithContext(reactor.core.publisher.Flux<T> publisher, io.opentelemetry.context.Context tracingContext)
    Forces Flux to run in traceContext scope.
    static <T> reactor.core.publisher.Mono<T>
    runWithContext(reactor.core.publisher.Mono<T> publisher, io.opentelemetry.context.Context tracingContext)
    Forces Mono to run in traceContext scope.
    static reactor.util.context.Context
    storeOpenTelemetryContext(reactor.util.context.Context context, io.opentelemetry.context.Context traceContext)
    Stores Trace Context in Reactor Context.

    Methods inherited from class java.lang.Object

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

    • create

      public static ContextPropagationOperator create()
    • builder

      public static ContextPropagationOperatorBuilder builder()
    • storeOpenTelemetryContext

      public static reactor.util.context.Context storeOpenTelemetryContext(reactor.util.context.Context context, io.opentelemetry.context.Context traceContext)
      Stores Trace Context in Reactor Context.
      Parameters:
      context - Reactor's context to store trace context in.
      traceContext - Trace context to be stored.
    • getOpenTelemetryContext

      public static io.opentelemetry.context.Context getOpenTelemetryContext(reactor.util.context.Context context, io.opentelemetry.context.Context defaultTraceContext)
      Gets Trace Context from Reactor Context.
      Parameters:
      context - Reactor's context to get trace context from.
      defaultTraceContext - Default value to be returned if no trace context is found on Reactor context.
      Returns:
      Trace context or default value.
    • getOpenTelemetryContextFromContextView

      public static io.opentelemetry.context.Context getOpenTelemetryContextFromContextView(reactor.util.context.ContextView contextView, io.opentelemetry.context.Context defaultTraceContext)
      Gets Trace Context from Reactor ContextView.
      Parameters:
      contextView - Reactor's context to get trace context from.
      defaultTraceContext - Default value to be returned if no trace context is found on Reactor context.
      Returns:
      Trace context or default value.
    • registerOnEachOperator

      public void registerOnEachOperator()
      Registers a hook that applies to every operator, propagating Context to downstream callbacks to ensure spans in the Context are available throughout the lifetime of a reactive stream. This should generally be called in a static initializer block in your application.
    • resetOnEachOperator

      public void resetOnEachOperator()
      Unregisters the hook registered by registerOnEachOperator().
    • runWithContext

      public static <T> reactor.core.publisher.Mono<T> runWithContext(reactor.core.publisher.Mono<T> publisher, io.opentelemetry.context.Context tracingContext)
      Forces Mono to run in traceContext scope.
    • runWithContext

      public static <T> reactor.core.publisher.Flux<T> runWithContext(reactor.core.publisher.Flux<T> publisher, io.opentelemetry.context.Context tracingContext)
      Forces Flux to run in traceContext scope.