> ## 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.

# Overview

> Attach context to your traces — users, sessions, tags, metadata, and more

Once you have initialized traceroot, LLM calls are traced automatically. To go further — tracing custom functions, identifying users, grouping sessions, or tracking cost — you can use `observe` and attach rich context to every trace.

## Quickstart

Here's everything you can attach in one place:

> [tab] Python
>
> ```python theme={null}
> import traceroot
> from traceroot import Integration, observe, using_attributes
> from openai import OpenAI
>
> traceroot.initialize(integrations=[Integration.OPENAI])
>
> client = OpenAI()
>
> @observe(name="run_agent", type="agent", metadata={"version": "v2"})
> def run_agent(query: str) -> str:
>     response = client.chat.completions.create(
>         model="gpt-4o",
>         messages=[{"role": "user", "content": query}]
>     )  # tokens + cost tracked automatically
>     return response.choices[0].message.content
>
> with using_attributes(user_id="user-42", session_id="chat-abc", tags=["production"]):
>     run_agent("What's the weather?")
>     run_agent("What about tomorrow?")
> ```

> [tab] TypeScript
>
> ```typescript theme={null}
> import OpenAI from 'openai';
> import { TraceRoot, observe, usingAttributes } from '@traceroot-ai/traceroot';
>
> TraceRoot.initialize({ instrumentModules: { openAI: OpenAI } });
>
> const client = new OpenAI();
>
> async function runAgent(query: string): Promise<string> {
>   return observe({ name: 'run_agent', type: 'agent', metadata: { version: 'v2' } }, async () => {
>     const response = await client.chat.completions.create({
>       model: 'gpt-4o',
>       messages: [{ role: 'user', content: query }]
>     }); // tokens + cost tracked automatically
>     return response.choices[0].message.content ?? '';
>   });
> }
>
> await usingAttributes(
>   { userId: 'user-42', sessionId: 'chat-abc', tags: ['production'] },
>   async () => {
>     await runAgent("What's the weather?");
>     await runAgent('What about tomorrow?');
>   },
> );
> ```

## Quick Reference

| I want to... | Attribute | Guide |
| - | - | - |
| Identify which user triggered a trace | User ID | [Users](https://traceroot.ai/docs/tracing/users.md) |
| Group traces from the same conversation | Session ID | [Sessions](https://traceroot.ai/docs/tracing/sessions.md) |
| Label traces for filtering | Tags | [Tags](https://traceroot.ai/docs/tracing/tags.md) |
| Attach structured key-value context | Metadata | [Metadata](https://traceroot.ai/docs/tracing/metadata.md) |
| Track token usage and LLM cost | auto via instrumentation | [Cost Tracking](https://traceroot.ai/docs/tracing/cost-tracking.md) |
| Link traces back to source code + commit | auto via `observe` | [Git Context](https://traceroot.ai/docs/tracing/git-context.md) |


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