OutputScope class
提供 OpenTelemetry 追蹤範圍,用於輸出訊息追蹤並結合父跨連結。
- Extends
方法
| record |
記錄輸出訊息以供遙測追蹤。 覆蓋該跨度上先前錄製的任何輸出訊息。 可接受單一字串、一組字串陣列(自動包裝為 OTEL OutputMessage)、版本化 OutputMessages 包裝器,或原始字典(依 OTEL 規範視為工具呼叫結果,直接序列化)。 |
| start(Request, Output |
建立並啟動新的輸出訊息追蹤範圍。 |
繼承的方法
| dispose() | 相容性遺留處理方法 |
| get |
了解這個範圍的跨度上下文。 這可以用來建立一個 ParentSpanRef,用於跨非同步邊界的明確父子連結。 |
| record |
記錄多個屬性鍵值對以進行遙測追蹤。 |
| record |
記錄橋樑上的取消事件。 將 span 狀態設為 ERROR,並以取消理由標示錯誤類型為「TaskCanceledException」。 |
| record |
記錄操作過程中發生的錯誤 |
| set |
為望遠鏡設定自訂結束時間。
設定後, 處置 會將此值傳遞給 , |
| with |
使此區間在非同步回調執行期間保持活躍 |
方法詳細資料
recordOutputMessages(ResponseMessagesParam)
記錄輸出訊息以供遙測追蹤。 覆蓋該跨度上先前錄製的任何輸出訊息。 可接受單一字串、一組字串陣列(自動包裝為 OTEL OutputMessage)、版本化 OutputMessages 包裝器,或原始字典(依 OTEL 規範視為工具呼叫結果,直接序列化)。
function recordOutputMessages(messages: ResponseMessagesParam)
參數
- messages
- ResponseMessagesParam
字串、字串陣列、OutputMessages 包裝器,或字譯。
start(Request, OutputResponse, AgentDetails, UserDetails, SpanDetails)
建立並啟動新的輸出訊息追蹤範圍。
static function start(request: Request, response: OutputResponse, agentDetails: AgentDetails, userDetails?: UserDetails, spanDetails?: SpanDetails): OutputScope
參數
- request
- Request
請求有效載荷(channel、conversationId、內容、sessionId)。
- response
- OutputResponse
回應包含初始輸出訊息。
- agentDetails
- AgentDetails
生產輸出的代理人。 租戶識別碼源自 agentDetails.tenantId。
- userDetails
- UserDetails
可選的人工來電者身份細節。
- spanDetails
- SpanDetails
可選的區間設定(parentContext、startTime、endTime、spanLinks)。
傳回
一個新的 OutputScope 實例。
繼承的方法的詳細資料
dispose()
getSpanContext()
了解這個範圍的跨度上下文。 這可以用來建立一個 ParentSpanRef,用於跨非同步邊界的明確父子連結。
function getSpanContext(): SpanContext
傳回
SpanContext
包含 traceId 與 spanId的 SpanContext
recordAttributes(undefined | null | Iterable<[string, AttributeValue]> | Record<string, AttributeValue>)
記錄多個屬性鍵值對以進行遙測追蹤。
function recordAttributes(attributes: undefined | null | Iterable<[string, AttributeValue]> | Record<string, AttributeValue>)
參數
- attributes
-
undefined | null | Iterable<[string, AttributeValue]> | Record<string, AttributeValue>
屬性鍵值對的集合(陣列或[鍵、值]或物件映射的迭代)。
recordCancellation(string)
記錄橋樑上的取消事件。 將 span 狀態設為 ERROR,並以取消理由標示錯誤類型為「TaskCanceledException」。
function recordCancellation(reason?: string)
參數
- reason
-
string
可選的取消原因。 預設為「任務已取消」。
recordError(Error)
記錄操作過程中發生的錯誤
function recordError(error: Error)
參數
- error
-
Error
發生的錯誤
setEndTime(TimeInput)
為望遠鏡設定自訂結束時間。
設定後, 處置 會將此值傳遞給 , span.end() 而非使用當前的壁鐘時間。
當操作的實際結束時間在示波器被處理前已知時,這非常有用。
function setEndTime(endTime: TimeInput)
參數
- endTime
-
TimeInput
結束時間以毫秒表示,從紀元、日期或 HrTime 元組開始。
withActiveSpanAsync<T>(() => Promise<T>)
使此區間在非同步回調執行期間保持活躍
function withActiveSpanAsync<T>(callback: () => Promise<T>): Promise<T>
參數
- callback
-
() => Promise<T>
傳回
Promise<T>