> ## Documentation Index
> Fetch the complete documentation index at: https://wb-21fd5541-sdk-testing-latest.mintlify.site/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 theme={null}
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>

[clientApi.ts:201](https://github.com/wandb/weave/blob/6538626556c93d6f31ae725fdefe4e6b8b71bc2c/sdks/node/src/clientApi.ts#L201)

***
