OpenTelemetryScope class

OpenTelemetry トレース スコープの基本クラス

メソッド

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>)

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

メソッドの詳細

dispose()

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

function 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>

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

recordCancellation(string)

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

function recordCancellation(reason?: string)

パラメーター

reason

string

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

recordError(Error)

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

function recordError(error: Error)

パラメーター

error

Error

発生したエラー

setEndTime(TimeInput)

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

function setEndTime(endTime: TimeInput)

パラメーター

endTime

TimeInput

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

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

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

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

パラメーター

callback

() => Promise<T>

返品

Promise<T>