ZoneContextManager This module provides an easy functionality for tracing action between asynchronous operations in web. It was not possible with standard [StackContextManager]https://github.com/open-telemetry/opentelemetry-js/blob/main/packages/opentelemetry-sdk-trace-web/src/StackContextManager.ts. It heavily depends on [zone.js]https://www.npmjs.com/package/zone.js. It stores the information about context in zone. Each Context will have always new Zone; It also supports binding a certain Span to a target that has "addEventListener" and "removeEventListener". When this happens a new zone is being created and the provided Span is being assigned to this zone.

Implements

Constructors

Methods

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

  • Calls the callback function [fn] with the provided [context]. If [context] is undefined then it will use the active context. The context will be set as active

    Type Parameters

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

    Parameters

    • context: null | Context

      A context (span) to be called with provided callback

    • fn: F

      Callback function

    • OptionalthisArg: ThisParameterType<F>

      optional receiver to be used for calling fn

    • ...args: A

      optional arguments forwarded to fn

    Returns ReturnType<F>