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

# Metadata

> Attach arbitrary key-value pairs to traces and spans

**Metadata** is key-value pairs attached to traces or spans — useful for model versions, request IDs, feature flags, or any structured context you want to search on.

## Using `observe`

Pass static metadata to `observe` for values known at definition time:

> [tab] Python
>
> ```python theme={null}
> from traceroot import observe
>
> @observe(name="process", type="agent", metadata={"version": "v2", "tier": "premium"})
> def process(query: str):
>     return result
> ```

> [tab] TypeScript
>
> ```typescript theme={null}
> import { observe } from '@traceroot-ai/traceroot';
>
> const result = await observe(
>   { name: 'process', type: 'agent', metadata: { version: 'v2', tier: 'premium' } },
>   async () => doWork(query),
> );
> ```

## Using `using_attributes` / `usingAttributes`

Propagate metadata to all traces and spans within a block:

> [tab] Python
>
> ```python theme={null}
> from traceroot import using_attributes
>
> with using_attributes(metadata={"deploy": "canary", "region": "us-west-2"}):
>     agent.run(query)
> ```

> [tab] TypeScript
>
> ```typescript theme={null}
> import { usingAttributes } from '@traceroot-ai/traceroot';
>
> await usingAttributes({ metadata: { deploy: 'canary', region: 'us-west-2' } }, async () => {
>   await agent.run(query);
> });
> ```


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.