Options
All
  • Public
  • Public/Protected
  • All
Menu

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

Hierarchy

  • ContextAPI

Index

Constructors

Private constructor

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

    Returns ContextAPI

Properties

Static Private Optional _instance

_instance: ContextAPI

Methods

Private _getContextManager

active

bind

  • bind<T>(context: Context, target: T): T
  • 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

  • disable(): void
  • Disable and remove the global context manager

    Returns void

setGlobalContextManager

  • Set the current context manager.

    Parameters

    Returns boolean

    true if the context manager was successfully registered, else false

with

  • with<A, F>(context: Context, fn: F, thisArg?: ThisParameterType<F>, ...args: A): ReturnType<F>
  • Execute a function with an active context

    Type parameters

    • A: unknown[]

    • F: (...args: A) => 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

    • Rest ...args: A

      optional arguments forwarded to fn

    Returns ReturnType<F>

Static getInstance