> ## Documentation Index
> Fetch the complete documentation index at: https://wb-21fd5541-docs-3071-org-scoped-api-keys.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# withAttributes

> TypeScript SDK リファレンス

> **withAttributes**\<`T`>(`attrs`, `fn`): `T` | `Promise`\<`T`>

現在の実行コンテキストに属性を追加すると、`fn` 内で作成されるすべての calls が
自動的にその属性を継承します。属性は trace サーバー上の call レコードに書き込まれ、
Weave UI での表示やフィルタリングに反映されるため、request ID、テナント、実験などで
runs にタグ付けするのに適しています。

例:

```ts twoslash theme={null}
// @noErrors
await withAttributes({requestId: 'abc'}, async () => {
  await myOp();
});
```

定義場所: [src/clientApi.ts:209](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/clientApi.ts#L209)

<div id="type-parameters">
  ## タイプパラメーター
</div>

<div id="t">
  ### T
</div>

`T`

<div id="parameters">
  ## パラメーター
</div>

<div id="attrs">
  ### attrs
</div>

`Record`\<`string`, `any`>

<div id="fn">
  ### fn
</div>

() => `T` | `Promise`\<`T`>

<div id="returns">
  ## 戻り値
</div>

`T` | `Promise`\<`T`>
