InvokeAgentScope class

AI エージェント呼び出し操作の OpenTelemetry トレース スコープを提供します。

Extends

メソッド

recordInputMessages(InputMessagesParam)

テレメトリ追跡用の入力メッセージを記録します。 1 つの文字列、文字列の配列 (ロールが userされた OTEL ChatMessage として自動ラップ)、またはバージョン管理された InputMessages ラッパーを受け取ります。

recordOutputMessages(OutputMessagesParam)

テレメトリ追跡用の出力メッセージを記録します。 1 つの文字列、文字列の配列 (ロールが assistantされた OTEL OutputMessage として自動ラップ)、またはバージョン管理された OutputMessages ラッパーを受け入れます。

recordResponse(string)

テレメトリ追跡の応答情報を記録します。

start(Request, InvokeAgentScopeDetails, AgentDetails, CallerDetails, SpanDetails)

エージェント呼び出しトレースの新しいスコープを作成して開始します。

継承されたメソッド

dispose()

互換性のための従来の dispose メソッド

getSpanContext()

このスコープのスパン コンテキストを取得します。 これを使用して、非同期境界を越えた明示的な親子リンク用の ParentSpanRef を作成できます。

recordAttributes(undefined | null | Iterable<[string, AttributeValue]> | Record<string, AttributeValue>)

テレメトリ追跡用に複数の属性キーと値のペアを記録します。

recordCancellation(string)

スパンのキャンセル イベントを記録します。 取り消し理由でスパンの状態を ERROR に設定し、エラーの種類を "TaskCanceledException" としてマークします。

recordError(Error)

操作中に発生したエラーを記録します

setEndTime(TimeInput)

スコープのカスタム終了時刻を設定します。 設定すると、 dispose はこの値を現在の実時間ではなく span.end() に渡します。 これは、スコープが破棄される前に、操作の実際の終了時刻がわかっている場合に便利です。

withActiveSpanAsync<T>(() => Promise<T>)

非同期コールバックの実行期間中、このスパンをアクティブにします

メソッドの詳細

recordInputMessages(InputMessagesParam)

テレメトリ追跡用の入力メッセージを記録します。 1 つの文字列、文字列の配列 (ロールが userされた OTEL ChatMessage として自動ラップ)、またはバージョン管理された InputMessages ラッパーを受け取ります。

function recordInputMessages(messages: InputMessagesParam)

パラメーター

messages
InputMessagesParam

文字列、文字列の配列、または InputMessages ラッパー

recordOutputMessages(OutputMessagesParam)

テレメトリ追跡用の出力メッセージを記録します。 1 つの文字列、文字列の配列 (ロールが assistantされた OTEL OutputMessage として自動ラップ)、またはバージョン管理された OutputMessages ラッパーを受け入れます。

function recordOutputMessages(messages: OutputMessagesParam)

パラメーター

messages
OutputMessagesParam

文字列、文字列の配列、または OutputMessages ラッパー

recordResponse(string)

テレメトリ追跡の応答情報を記録します。

function recordResponse(response: string)

パラメーター

response

string

呼び出し応答

start(Request, InvokeAgentScopeDetails, AgentDetails, CallerDetails, SpanDetails)

エージェント呼び出しトレースの新しいスコープを作成して開始します。

static function start(request: Request, invokeScopeDetails: InvokeAgentScopeDetails, agentDetails: AgentDetails, callerDetails?: CallerDetails, spanDetails?: SpanDetails): InvokeAgentScope

パラメーター

request
Request

要求ペイロード (チャネル、conversationId、コンテンツ、sessionId)。

invokeScopeDetails
InvokeAgentScopeDetails

スコープ レベルの詳細

agentDetails
AgentDetails

エージェント ID。 テナント ID は、 agentDetails.tenantId (必須) から派生します。

callerDetails
CallerDetails

オプションの呼び出し元情報。 次の 3 つのシナリオをサポートします。

  • 人間の呼び出し元のみ: { userDetails: { userId, userName, ... } }
  • エージェントの呼び出し元のみ: { callerAgentDetails: { agentId, agentName, ... } }
  • 両方 (A2A と人間の連鎖): { userDetails: { ... }, callerAgentDetails: { ... } }
spanDetails
SpanDetails

オプションのスパン構成 (parentContext、startTime、endTime、spanKind、spanLinks)。

返品

新しい InvokeAgentScope インスタンス。

継承済みメソッドの詳細

dispose()

互換性のための従来の dispose メソッド

function dispose()

Inherited FromOpenTelemetryScope.dispose

getSpanContext()

このスコープのスパン コンテキストを取得します。 これを使用して、非同期境界を越えた明示的な親子リンク用の ParentSpanRef を作成できます。

function getSpanContext(): SpanContext

返品

SpanContext

traceId と spanId を含む SpanContext

Inherited FromOpenTelemetryScope.getSpanContext

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>

属性キーと値のペアのコレクション (配列または [キー、値] またはオブジェクト マップの iterable)。

Inherited FromOpenTelemetryScope.recordAttributes

recordCancellation(string)

スパンのキャンセル イベントを記録します。 取り消し理由でスパンの状態を ERROR に設定し、エラーの種類を "TaskCanceledException" としてマークします。

function recordCancellation(reason?: string)

パラメーター

reason

string

省略可能な取り消し理由。 既定値は 'Task was cancelled' です。

Inherited FromOpenTelemetryScope.recordCancellation

recordError(Error)

操作中に発生したエラーを記録します

function recordError(error: Error)

パラメーター

error

Error

発生したエラー

Inherited FromOpenTelemetryScope.recordError

setEndTime(TimeInput)

スコープのカスタム終了時刻を設定します。 設定すると、 dispose はこの値を現在の実時間ではなく span.end() に渡します。 これは、スコープが破棄される前に、操作の実際の終了時刻がわかっている場合に便利です。

function setEndTime(endTime: TimeInput)

パラメーター

endTime

TimeInput

エポック、Date、または HrTime タプルからの終了時刻 (ミリ秒)。

Inherited FromOpenTelemetryScope.setEndTime

withActiveSpanAsync<T>(() => Promise<T>)

非同期コールバックの実行期間中、このスパンをアクティブにします

function withActiveSpanAsync<T>(callback: () => Promise<T>): Promise<T>

パラメーター

callback

() => Promise<T>

返品

Promise<T>

OpenTelemetryScope.withActiveSpanAsyncから継承