ApplyGuardrailScope class

セキュリティ ガードレール評価操作用の OpenTelemetry トレース スコープを提供します。

セキュリティ ガーディアンの評価について説明します。 複数のガーディアンがチェーンされている場合、1 つの操作スパンの下に複数のガーディアン スパンが存在する場合があります(MAY)。

ガーディアン スパンは、保護している操作スパンの子である必要があります (推論やexecute_toolスパンなど)。

Extends

メソッド

recordContentOutput(string)

ガードレール評価 (オプトイン) の出力コンテンツ値を記録します。

recordDecision(GuardrailDecisionType, string)

ガードレール スパンに関する更新された決定を記録します。 スパンの作成後にガードレールの決定が決定される場合に使用します。

recordFinding(GuardrailFinding)

現在のスパンのセキュリティ検索イベントを記録します。 ガードレール評価ごとに複数の所見を記録することができます。

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

ガードレール評価トレースの新しいスコープを作成して開始します。

継承されたメソッド

dispose()

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

getSpanContext()

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

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

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

recordCancellation(string)

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

recordError(Error)

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

setEndTime(TimeInput)

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

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

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

[dispose]()

スコープを破棄し、テレメトリ データの収集を完了します

メソッドの詳細

recordContentOutput(string)

ガードレール評価 (オプトイン) の出力コンテンツ値を記録します。

function recordContentOutput(outputValue: string)

パラメーター

outputValue

string

ガードレール処理後の出力コンテンツ。

recordDecision(GuardrailDecisionType, string)

ガードレール スパンに関する更新された決定を記録します。 スパンの作成後にガードレールの決定が決定される場合に使用します。

function recordDecision(decisionType: GuardrailDecisionType, reason?: string)

パラメーター

decisionType
GuardrailDecisionType

ガーディアンによって行われた決定の種類。

reason

string

意思決定に関する人間が判読できる省略可能な説明。

recordFinding(GuardrailFinding)

現在のスパンのセキュリティ検索イベントを記録します。 ガードレール評価ごとに複数の所見を記録することができます。

function recordFinding(finding: GuardrailFinding)

パラメーター

finding
GuardrailFinding

記録するセキュリティの検出。

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

ガードレール評価トレースの新しいスコープを作成して開始します。

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

パラメーター

details
GuardrailDetails

ガードレール評価の詳細 (ターゲット、決定、ガーディアン情報、ポリシー)。

agentDetails
AgentDetails

保護されているエージェントに関する情報。

request
Request

会話コンテキストの省略可能な要求の詳細。

userDetails
UserDetails

省略可能な人間のユーザーの詳細。

spanDetails
SpanDetails

オプションのスパン構成 (親コンテキスト、タイミング、種類、スパン リンク)。

戻り値

新しい ApplyGuardrailScope インスタンス。

継承済みメソッドの詳細

dispose()

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

function dispose()

Inherited FromOpenTelemetryScope.dispose

getSpanContext()

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

function getSpanContext(): SpanContext

戻り値

SpanContext

traceId と spanId を含む SpanContext

Inherited FromOpenTelemetryScope.getSpanContext

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

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

function recordAttributes(attributes: Iterable<[string, AttributeValue], any, any> | Record<string, AttributeValue> | null | undefined)

パラメーター

attributes

Iterable<[string, AttributeValue], any, any> | Record<string, AttributeValue> | null | undefined

属性キーと値のペアのコレクション (配列または [キー、値] またはオブジェクト マップの 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から継承

[dispose]()

スコープを破棄し、テレメトリ データの収集を完了します

function [dispose]()

Inherited FromOpenTelemetryScope.[dispose]