> ## Documentation Index
> Fetch the complete documentation index at: https://docs.wandb.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# withAttributes

> TypeScript SDK のリファレンス

<div id="withattributes">
  # withAttributes
</div>

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

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

例:

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

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

| 名   |
| :-- |
| `T` |

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

| 名       | タイプ                        |                 |
| :------ | :------------------------- | --------------- |
| `attrs` | `Record`\<`string`, `any`> |                 |
| `fn`    | () => `T`                  | `Promise`\<`T`> |

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

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

<div id="defined-in">
  #### 定義元
</div>

[src/clientApi.ts:194](https://github.com/wandb/weave/blob/9591aba8a5e77309ee0858e5ba94d31c1bd7e404/sdks/node/src/clientApi.ts#L194)

***
