メインコンテンツへスキップ

withAttributes

withAttributes<T>(attrs, fn): Promise<T> | T 現在の実行コンテキストに属性をアタッチし、 fn 内で作成されるすべてのコールが自動的にそれらを継承するようにします。属性はトレースサーバー上のコールレコードに書き込まれ、 Weave UIやフィルタリングに表示されます。そのため、リクエストID、テナント、 Experiments などのタグを Runs に付与するのに最適です。 Example:
await withAttributes({requestId: 'abc'}, async () => {
  await myOp();
});

Type parameters

Name
T

Parameters

NameType
attrsRecord<string, any>
fn() => T | Promise<T>

Returns

Promise<T> | T

Defined in

clientApi.ts:193