BaggageScope class

Context manager for baggage scope.

Manages the lifecycle of baggage values, setting them in the OTel context and restoring the previous context when the scope ends.

Methods

dispose()

Manual cleanup alternative if caller isn't using using.

run<T>(() => T)

Execute a synchronous function under this baggage scope. Automatically restores previous context afterward.

[dispose]()

Dispose is a no-op because OpenTelemetry JS automatically restores the previous context after context.with() completes.

Constructor Details

BaggageScope(Map<string, string>)

new BaggageScope(pairs: Map<string, string>)

Parameters

pairs

Map<string, string>

Method Details

dispose()

Manual cleanup alternative if caller isn't using using.

function dispose()

run<T>(() => T)

Execute a synchronous function under this baggage scope. Automatically restores previous context afterward.

function run<T>(fn: () => T): T

Parameters

fn

() => T

Returns

T

[dispose]()

Dispose is a no-op because OpenTelemetry JS automatically restores the previous context after context.with() completes.

function [dispose]()