BaggageBuilder class
OpenTelemetry 上下文传播的每个请求行李生成器。
此类提供了一个 Fluent API,用于设置将在 OpenTelemetry 上下文中传播的行李值。
示例
const scope = new BaggageBuilder()
.tenantId("tenant-123")
.agentId("agent-456")
.build();
scope.enter();
// Baggage is set in this context
// ... do work ...
scope.exit();
// Baggage is restored after exiting the context
方法
方法详细信息
agentAuid(undefined | null | string)
设置代理 AUID 行李值。
function agentAuid(value: undefined | null | string): BaggageBuilder
参数
- value
-
undefined | null | string
代理 AUID
返回
自链接方法
agentBlueprintId(undefined | null | string)
设置代理蓝图 ID 行李值。
function agentBlueprintId(value: undefined | null | string): BaggageBuilder
参数
- value
-
undefined | null | string
代理蓝图 ID
返回
自链接方法
agentDescription(undefined | null | string)
设置代理说明行李值。
function agentDescription(value: undefined | null | string): BaggageBuilder
参数
- value
-
undefined | null | string
代理说明
返回
自链接方法
agentEmail(undefined | null | string)
设置代理电子邮件行李值。
function agentEmail(value: undefined | null | string): BaggageBuilder
参数
- value
-
undefined | null | string
代理电子邮件
返回
自链接方法
agentId(undefined | null | string)
设置代理 ID 行李值。
function agentId(value: undefined | null | string): BaggageBuilder
参数
- value
-
undefined | null | string
代理 ID
返回
自链接方法
agentName(undefined | null | string)
设置代理名称行李值。
function agentName(value: undefined | null | string): BaggageBuilder
参数
- value
-
undefined | null | string
代理名称
返回
自链接方法
agentPlatformId(undefined | null | string)
设置代理平台 ID 行李值。
function agentPlatformId(value: undefined | null | string): BaggageBuilder
参数
- value
-
undefined | null | string
代理平台 ID
返回
自链接方法
agentVersion(undefined | null | string)
设置代理版本行李值。
function agentVersion(value: undefined | null | string): BaggageBuilder
参数
- value
-
undefined | null | string
代理版本(例如,“1.0.0”、“2025-05-01”)
返回
自链接方法
build()
callerAgentPlatformId(undefined | null | string)
设置调用方代理平台 ID 行李值。
function callerAgentPlatformId(value: undefined | null | string): BaggageBuilder
参数
- value
-
undefined | null | string
调用方代理平台标识符
返回
自链接方法
callerClientIp(undefined | null | string)
设置调用方客户端 IP 行李值。 用于捕获请求的发起客户端 IP,以便可以通过 OpenTelemetry 行李传播它。
function callerClientIp(value: undefined | null | string): BaggageBuilder
参数
- value
-
undefined | null | string
调用方客户端 IP 地址
返回
自链接方法
channelLink(undefined | null | string)
设置通道链接/URL。
function channelLink(value: undefined | null | string): BaggageBuilder
参数
- value
-
undefined | null | string
通道链接
返回
自链接方法
channelName(undefined | null | string)
设置频道名称(例如 Teams、Slack)。
function channelName(value: undefined | null | string): BaggageBuilder
参数
- value
-
undefined | null | string
通道名称
返回
自链接方法
conversationId(undefined | null | string)
设置对话 ID 行李值。
function conversationId(value: undefined | null | string): BaggageBuilder
参数
- value
-
undefined | null | string
会话 ID
返回
自链接方法
conversationItemLink(undefined | null | string)
设置对话项目链接行李值。
function conversationItemLink(value: undefined | null | string): BaggageBuilder
参数
- value
-
undefined | null | string
对话项链接
返回
自链接方法
invokeAgentServer(undefined | null | string, number)
设置调用代理服务器地址和端口行李值。
function invokeAgentServer(address: undefined | null | string, port?: number): BaggageBuilder
参数
- address
-
undefined | null | string
目标代理服务的服务器地址(主机名)。
- port
-
number
可选服务器端口。 仅当与 443 不同时才会记录。
返回
方法链接的当前生成器实例。
operationSource(undefined | null | string)
设置作源行李值。 用于服务器范围来标识服务(例如 ATG、ACF)。
function operationSource(value: undefined | null | string): BaggageBuilder
参数
- value
-
undefined | null | string
操作源
返回
自链接方法
sessionDescription(undefined | null | string)
设置会话说明行李值。
function sessionDescription(value: undefined | null | string): BaggageBuilder
参数
- value
-
undefined | null | string
会话说明
返回
自链接方法
sessionId(string)
设置会话 ID 行李值。
function sessionId(value: string): BaggageBuilder
参数
- value
-
string
会话 ID
返回
自链接方法
setPairs(undefined | null | Record<string, any> | Iterable<[string, any]>)
从字典或可迭代设置多个行李对。
function setPairs(pairs: undefined | null | Record<string, any> | Iterable<[string, any]>): BaggageBuilder
参数
- pairs
-
undefined | null | Record<string, any> | Iterable<[string, any]>
键值对的字典或可迭代
返回
自链接方法
setRequestContext(null | string, null | string)
使用常用字段开始请求行李范围的便利方法。
static function setRequestContext(tenantId?: null | string, agentId?: null | string): BaggageScope
参数
- tenantId
-
null | string
租户 ID
- agentId
-
null | string
代理 ID
返回
在退出时还原上一个行李的上下文管理器
tenantId(undefined | null | string)
设置租户 ID 行李值。
function tenantId(value: undefined | null | string): BaggageBuilder
参数
- value
-
undefined | null | string
租户 ID
返回
自链接方法
userEmail(undefined | null | string)
设置用户电子邮件行李值。
function userEmail(value: undefined | null | string): BaggageBuilder
参数
- value
-
undefined | null | string
用户电子邮件
返回
自链接方法
userId(undefined | null | string)
设置用户 ID 行李值。
function userId(value: undefined | null | string): BaggageBuilder
参数
- value
-
undefined | null | string
用户 ID
返回
自链接方法
userName(undefined | null | string)
设置用户名行李值。
function userName(value: undefined | null | string): BaggageBuilder
参数
- value
-
undefined | null | string
用户名
返回
自链接方法