OpenTelemetry SDK
    Preparing search index...

    Hierarchy

    • AbstractAsyncHooksContextManager
      • AsyncLocalStorageContextManager
    Index
    • Experimental

      Imperatively sets context as active for the current async execution chain and operations spawned from it. Returns a ContextManagementToken whose dispose() restores the previous context (see ContextManager.attach).

      On Node.js 25.9+, delegates to AsyncLocalStorage.withScope() which returns a native RunScope. On older Node.js versions, falls back to enterWith() with a manual token.

      Caveat for async functions: Both withScope() and enterWith() affect the entire current async execution chain. If attach() is called inside an async function before the first await, the context change will leak into the caller's context and remain active there until something else restores it. Prefer with() for async code.

      This API is experimental and may change in minor releases without prior notice.

      Parameters

      Returns ContextManagementToken

    • Binds a the certain context or the active one to the target function and then returns the target

      Type Parameters

      • T

      Parameters

      • context: Context

        A context (span) to be bind to target

      • target: T

        a function or event emitter. When target or one of its callbacks is called, the provided context will be used as the active context for the duration of the call.

      Returns T

    • Type Parameters

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

      Parameters

      • context: Context
      • fn: F
      • OptionalthisArg: ThisParameterType<F>
      • ...args: A

      Returns ReturnType<F>