OpenTelemetry SDK
    Preparing search index...

    Singleton object which represents the entry point to the OpenTelemetry Context API

    1.0.0

    interface ContextAPI {
        active(): @opentelemetry/api.Context;
        bind<T>(context: @opentelemetry/api.Context, target: T): T;
        disable(): void;
        setGlobalContextManager(
            contextManager: @opentelemetry/api.ContextManager,
        ): boolean;
        with<A extends unknown[], F extends (...args: A) => ReturnType<F>>(
            context: @opentelemetry/api.Context,
            fn: F,
            thisArg?: ThisParameterType<F>,
            ...args: A,
        ): ReturnType<F>;
    }
    Index

    Methods

    • Bind a context to a target function or event emitter

      Type Parameters

      • T

      Parameters

      • context: @opentelemetry/api.Context

        context to bind to the event emitter or function. Defaults to the currently active context

      • target: T

        function or event emitter to bind

      Returns T

    • Disable and remove the global context manager

      Returns void

    • Execute a function with an active context

      Type Parameters

      • A extends unknown[]
      • F extends (...args: A) => ReturnType<F>

      Parameters

      • context: @opentelemetry/api.Context

        context to be active during function execution

      • fn: F

        function to execute in a context

      • OptionalthisArg: ThisParameterType<F>

        optional receiver to be used for calling fn

      • ...args: A

        optional arguments forwarded to fn

      Returns ReturnType<F>