次の方法で共有


InferenceScope class

生成 AI 推論操作用の OpenTelemetry トレース スコープを提供します。

Extends

メソッド

recordFinishReasons(string[])

テレメトリ追跡の完了理由を記録します。

recordInputMessages(InputMessagesParam)

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

recordInputTokens(number)

テレメトリ追跡用の入力トークンの数を記録します。

recordOutputMessages(OutputMessagesParam)

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

recordOutputTokens(number)

テレメトリ追跡用の出力トークンの数を記録します。

start(Request, InferenceDetails, AgentDetails, UserDetails, 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>)

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

メソッドの詳細

recordFinishReasons(string[])

テレメトリ追跡の完了理由を記録します。

function recordFinishReasons(finishReasons: string[])

パラメーター

finishReasons

string[]

終了理由の配列

recordInputMessages(InputMessagesParam)

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

function recordInputMessages(messages: InputMessagesParam)

パラメーター

messages
InputMessagesParam

入力メッセージ文字列または InputMessages ラッパーの配列

recordInputTokens(number)

テレメトリ追跡用の入力トークンの数を記録します。

function recordInputTokens(inputTokens: number)

パラメーター

inputTokens

number

入力トークンの数

recordOutputMessages(OutputMessagesParam)

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

function recordOutputMessages(messages: OutputMessagesParam)

パラメーター

messages
OutputMessagesParam

出力メッセージ文字列または OutputMessages ラッパーの配列

recordOutputTokens(number)

テレメトリ追跡用の出力トークンの数を記録します。

function recordOutputTokens(outputTokens: number)

パラメーター

outputTokens

number

出力トークンの数

start(Request, InferenceDetails, AgentDetails, UserDetails, SpanDetails)

推論トレースの新しいスコープを作成して開始します。

static function start(request: Request, details: InferenceDetails, agentDetails: AgentDetails, userDetails?: UserDetails, spanDetails?: SpanDetails): InferenceScope

パラメーター

request
Request

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

details
InferenceDetails

推論呼び出しの詳細 (モデル、プロバイダー、トークンなど)。

agentDetails
AgentDetails

推論を実行しているエージェント。 テナント ID は、 agentDetails.tenantIdから派生します。

userDetails
UserDetails

オプションの人間の呼び出し元 ID。

spanDetails
SpanDetails

オプションのスパン構成 (parentContext、startTime、endTime、spanLinks)。 注: spanKind は無視されます。InferenceScope では常に SpanKind.CLIENTが使用されます。

返品

新しい InferenceScope インスタンス

継承済みメソッドの詳細

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から継承