BaggageBuilder Class

Per request baggage builder.

This class provides a fluent API for setting baggage values that will be propagated in the OpenTelemetry context.

Initialize the baggage builder.

Constructor

BaggageBuilder()

Examples


   builder = (BaggageBuilder()
              .tenant_id("tenant-123")
              .agent_id("agent-456"))

   with builder.build():
       # Baggage is set in this context
       pass
   # Baggage is restored after exiting the context

Methods

agent_blueprint_id

Set the agent blueprint ID baggage value.

agent_description

Set the agent description baggage value.

agent_id

Set the agent ID baggage value.

agent_name

Set the agent name baggage value.

agent_version

Set the agent version baggage value.

agentic_user_email

Set the agentic user email baggage value.

agentic_user_id

Set the agentic user ID baggage value.

build

Apply the collected baggage to the current context.

channel_links

Sets the channel link baggage value.

channel_name

Sets the channel name baggage value (e.g., 'Teams', 'msteams').

conversation_id

Set the conversation ID baggage value.

conversation_item_link

Set the conversation item link baggage value.

invoke_agent_server

Set the invoke agent server address and port baggage values.

operation_source

Set the operation source baggage value.

This captures the name of the service using the SDK.

session_description

Set the session description baggage value.

session_id

Set the session ID baggage value.

set_pairs

Accept dict or iterable of (k,v).

tenant_id

Set the tenant ID baggage value.

user_client_ip

Set the user client IP baggage value.

user_email

Set the user email baggage value.

user_id

Set the user ID baggage value.

user_name

Set the user name baggage value.

agent_blueprint_id

Set the agent blueprint ID baggage value.

agent_blueprint_id(value: str | None) -> BaggageBuilder

Parameters

Name Description
value
Required

The agent blueprint ID

Returns

Type Description

Self for method chaining

agent_description

Set the agent description baggage value.

agent_description(value: str | None) -> BaggageBuilder

Parameters

Name Description
value
Required

agent_id

Set the agent ID baggage value.

agent_id(value: str | None) -> BaggageBuilder

Parameters

Name Description
value
Required

The agent ID

Returns

Type Description

Self for method chaining

agent_name

Set the agent name baggage value.

agent_name(value: str | None) -> BaggageBuilder

Parameters

Name Description
value
Required

agent_version

Set the agent version baggage value.

agent_version(value: str | None) -> BaggageBuilder

Parameters

Name Description
value
Required

agentic_user_email

Set the agentic user email baggage value.

agentic_user_email(value: str | None) -> BaggageBuilder

Parameters

Name Description
value
Required

The agentic user email

Returns

Type Description

Self for method chaining

agentic_user_id

Set the agentic user ID baggage value.

agentic_user_id(value: str | None) -> BaggageBuilder

Parameters

Name Description
value
Required

The agentic user ID

Returns

Type Description

Self for method chaining

build

Apply the collected baggage to the current context.

build() -> BaggageScope

Returns

Type Description

A context manager that restores the previous baggage on exit

Sets the channel link baggage value.

channel_links(value: str | None) -> BaggageBuilder

Parameters

Name Description
value
Required

channel_name

Sets the channel name baggage value (e.g., 'Teams', 'msteams').

channel_name(value: str | None) -> BaggageBuilder

Parameters

Name Description
value
Required

conversation_id

Set the conversation ID baggage value.

conversation_id(value: str | None) -> BaggageBuilder

Parameters

Name Description
value
Required

Set the conversation item link baggage value.

conversation_item_link(value: str | None) -> BaggageBuilder

Parameters

Name Description
value
Required

invoke_agent_server

Set the invoke agent server address and port baggage values.

invoke_agent_server(address: str | None, port: int | None = None) -> BaggageBuilder

Parameters

Name Description
address
Required

The server address (hostname) of the target agent service.

port

Optional server port. Only recorded when different from 443.

Default value: None

Returns

Type Description

Self for method chaining

operation_source

Set the operation source baggage value.

This captures the name of the service using the SDK.

operation_source(value: str | None) -> BaggageBuilder

Parameters

Name Description
value
Required

The service name (e.g., "my-agent-service", "weather-bot")

Returns

Type Description

Self for method chaining

session_description

Set the session description baggage value.

session_description(value: str | None) -> BaggageBuilder

Parameters

Name Description
value
Required

session_id

Set the session ID baggage value.

session_id(value: str | None) -> BaggageBuilder

Parameters

Name Description
value
Required

set_pairs

Accept dict or iterable of (k,v).

set_pairs(pairs: Any) -> BaggageBuilder

Parameters

Name Description
pairs
Required

tenant_id

Set the tenant ID baggage value.

tenant_id(value: str | None) -> BaggageBuilder

Parameters

Name Description
value
Required

The tenant ID

Returns

Type Description

Self for method chaining

user_client_ip

Set the user client IP baggage value.

user_client_ip(value: str | None) -> BaggageBuilder

Parameters

Name Description
value
Required

user_email

Set the user email baggage value.

user_email(value: str | None) -> BaggageBuilder

Parameters

Name Description
value
Required

user_id

Set the user ID baggage value.

user_id(value: str | None) -> BaggageBuilder

Parameters

Name Description
value
Required

The user ID

Returns

Type Description

Self for method chaining

user_name

Set the user name baggage value.

user_name(value: str | None) -> BaggageBuilder

Parameters

Name Description
value
Required