Class ContextAPI

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

Hierarchy

  • ContextAPI

Constructors

  • Empty private constructor prevents end users from constructing a new instance of the API

    Returns ContextAPI

Properties

_getContextManager: any
_instance?: any

Methods

  • Get the currently active context

    Returns Context

  • Bind a context to a target function or event emitter

    Type Parameters

    • T

    Parameters

    • context: 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

  • Set the current context manager.

    Parameters

    Returns boolean

    true if the context manager was successfully registered, else false

  • Execute a function with an active context

    Type Parameters

    • A extends unknown[]

    • F extends ((...args) => ReturnType<F>)

    Parameters

    • context: Context

      context to be active during function execution

    • fn: F

      function to execute in a context

    • Optional thisArg: ThisParameterType<F>

      optional receiver to be used for calling fn

      Optional
    • Rest ...args: A

      optional arguments forwarded to fn

      Rest

    Returns ReturnType<F>

  • Get the singleton instance of the Context API

    Returns ContextAPI

Generated using TypeDoc