Options
All
  • Public
  • Public/Protected
  • All
Menu

Class ContextAPI

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

Hierarchy

  • ContextAPI

Index

Constructors

Private constructor

Properties

Private _contextManager

_contextManager: ContextManager = new NoopContextManager()

Static Private Optional _instance

_instance: ContextAPI

Methods

active

  • active(): Context

bind

  • bind<T>(target: T, context?: Context): T
  • Bind a context to a target function or event emitter

    Type parameters

    • T

    Parameters

    • target: T

      function or event emitter to bind

    • Default value context: Context = this.active()

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

    Returns T

setGlobalContextManager

  • setGlobalContextManager(contextManager: ContextManager): ContextManager
  • Set the current context manager. Returns the initialized context manager

    Parameters

    • contextManager: ContextManager

    Returns ContextManager

with

  • with<T>(context: Context, fn: T): ReturnType<T>
  • Execute a function with an active context

    Type parameters

    • T: function

    Parameters

    • context: Context

      context to be active during function execution

    • fn: T

      function to execute in a context

    Returns ReturnType<T>

Static getInstance