BaggageBuilder class
Per request baggage builder for OpenTelemetry context propagation.
This class provides a fluent API for setting baggage values that will be propagated in the OpenTelemetry context.
Example
const scope = new BaggageBuilder()
.tenantId("tenant-123")
.agentId("agent-456")
.correlationId("corr-789")
.build();
scope.enter();
// Baggage is set in this context
// ... do work ...
scope.exit();
// Baggage is restored after exiting the context
Methods
| agent |
Set the agent AUID baggage value. |
| agent |
Set the agent blueprint ID baggage value. |
| agent |
Set the agent description baggage value. |
| agent |
Set the agent ID baggage value. |
| agent |
Set the agent name baggage value. |
| agent |
Set the agent UPN baggage value. |
| build() | Apply the collected baggage to the current context. |
| caller |
Set the caller ID baggage value. |
| caller |
Set the caller name baggage value. |
| caller |
Set the caller UPN baggage value. |
| conversation |
Set the conversation ID baggage value. |
| conversation |
Set the conversation item link baggage value. |
| correlation |
Set the correlation ID baggage value. |
| hiring |
Set the hiring manager ID baggage value. |
| operation |
Set the operation source baggage value. |
| set |
Set multiple baggage pairs from a dictionary or iterable. |
| set |
Convenience method to begin a request baggage scope with common fields. |
| source |
Set the execution source metadata description (e.g., channel description). |
| source |
Set the execution source metadata ID (e.g., channel ID). |
| source |
Set the execution source metadata name (e.g., channel name). |
| tenant |
Set the tenant ID baggage value. |
Method Details
agentAuid(undefined | null | string)
Set the agent AUID baggage value.
function agentAuid(value: undefined | null | string): BaggageBuilder
Parameters
- value
-
undefined | null | string
The agent AUID
Returns
Self for method chaining
agentBlueprintId(undefined | null | string)
Set the agent blueprint ID baggage value.
function agentBlueprintId(value: undefined | null | string): BaggageBuilder
Parameters
- value
-
undefined | null | string
The agent blueprint ID
Returns
Self for method chaining
agentDescription(undefined | null | string)
Set the agent description baggage value.
function agentDescription(value: undefined | null | string): BaggageBuilder
Parameters
- value
-
undefined | null | string
The agent description
Returns
Self for method chaining
agentId(undefined | null | string)
Set the agent ID baggage value.
function agentId(value: undefined | null | string): BaggageBuilder
Parameters
- value
-
undefined | null | string
The agent ID
Returns
Self for method chaining
agentName(undefined | null | string)
Set the agent name baggage value.
function agentName(value: undefined | null | string): BaggageBuilder
Parameters
- value
-
undefined | null | string
The agent name
Returns
Self for method chaining
agentUpn(undefined | null | string)
Set the agent UPN baggage value.
function agentUpn(value: undefined | null | string): BaggageBuilder
Parameters
- value
-
undefined | null | string
The agent UPN
Returns
Self for method chaining
build()
Apply the collected baggage to the current context.
function build(): BaggageScope
Returns
A context manager that restores the previous baggage on exit
callerId(undefined | null | string)
Set the caller ID baggage value.
function callerId(value: undefined | null | string): BaggageBuilder
Parameters
- value
-
undefined | null | string
The caller ID
Returns
Self for method chaining
callerName(undefined | null | string)
Set the caller name baggage value.
function callerName(value: undefined | null | string): BaggageBuilder
Parameters
- value
-
undefined | null | string
The caller name
Returns
Self for method chaining
callerUpn(undefined | null | string)
Set the caller UPN baggage value.
function callerUpn(value: undefined | null | string): BaggageBuilder
Parameters
- value
-
undefined | null | string
The caller UPN
Returns
Self for method chaining
conversationId(undefined | null | string)
Set the conversation ID baggage value.
function conversationId(value: undefined | null | string): BaggageBuilder
Parameters
- value
-
undefined | null | string
The conversation ID
Returns
Self for method chaining
conversationItemLink(undefined | null | string)
Set the conversation item link baggage value.
function conversationItemLink(value: undefined | null | string): BaggageBuilder
Parameters
- value
-
undefined | null | string
The conversation item link
Returns
Self for method chaining
correlationId(undefined | null | string)
Set the correlation ID baggage value.
function correlationId(value: undefined | null | string): BaggageBuilder
Parameters
- value
-
undefined | null | string
The correlation ID
Returns
Self for method chaining
hiringManagerId(undefined | null | string)
Set the hiring manager ID baggage value.
function hiringManagerId(value: undefined | null | string): BaggageBuilder
Parameters
- value
-
undefined | null | string
The hiring manager ID
Returns
Self for method chaining
operationSource(undefined | null | string)
Set the operation source baggage value.
function operationSource(value: undefined | null | string): BaggageBuilder
Parameters
- value
-
undefined | null | string
The operation source value
Returns
Self for method chaining
setPairs(undefined | null | Record<string, any> | Iterable<[string, any]>)
Set multiple baggage pairs from a dictionary or iterable.
function setPairs(pairs: undefined | null | Record<string, any> | Iterable<[string, any]>): BaggageBuilder
Parameters
- pairs
-
undefined | null | Record<string, any> | Iterable<[string, any]>
Dictionary or iterable of key-value pairs
Returns
Self for method chaining
setRequestContext(null | string, null | string, null | string)
Convenience method to begin a request baggage scope with common fields.
static function setRequestContext(tenantId?: null | string, agentId?: null | string, correlationId?: null | string): BaggageScope
Parameters
- tenantId
-
null | string
The tenant ID
- agentId
-
null | string
The agent ID
- correlationId
-
null | string
The correlation ID
Returns
A context manager that restores the previous baggage on exit
sourceMetadataDescription(undefined | null | string)
Set the execution source metadata description (e.g., channel description).
function sourceMetadataDescription(value: undefined | null | string): BaggageBuilder
Parameters
- value
-
undefined | null | string
The source metadata description
Returns
Self for method chaining
sourceMetadataId(undefined | null | string)
Set the execution source metadata ID (e.g., channel ID).
function sourceMetadataId(value: undefined | null | string): BaggageBuilder
Parameters
- value
-
undefined | null | string
The source metadata ID
Returns
Self for method chaining
sourceMetadataName(undefined | null | string)
Set the execution source metadata name (e.g., channel name).
function sourceMetadataName(value: undefined | null | string): BaggageBuilder
Parameters
- value
-
undefined | null | string
The source metadata name
Returns
Self for method chaining
tenantId(undefined | null | string)
Set the tenant ID baggage value.
function tenantId(value: undefined | null | string): BaggageBuilder
Parameters
- value
-
undefined | null | string
The tenant ID
Returns
Self for method chaining