Quick Reference
| Concept | OTEL Attribute | REST API | Description |
|---|---|---|---|
| Thread/Conversation | gen_ai.conversation.id | metadata.thread_id | Groups messages in a conversation |
| User ID | langwatch.user.id | metadata.user_id | Identifies the end user |
| Customer ID | langwatch.customer.id | metadata.customer_id | Your platform’s customer/tenant |
| Labels | langwatch.labels | metadata.labels | Categorization tags |
| Custom Metadata | metadata attribute | metadata.* | Any additional context |
For OTEL,
gen_ai.conversation.id follows the OpenTelemetry GenAI semantic conventions. The legacy langwatch.thread.id attribute is also supported.SDK Examples
For detailed SDK-specific tutorials, see:- TypeScript: Capturing Metadata · Tracking Conversations · Full example
- Python: Capturing Metadata · Tracking Conversations · Full example
Raw OpenTelemetry
If you’re using vanilla OpenTelemetry without the LangWatch SDK:REST API
Send traces directly via HTTP. See REST API for full details.Reserved vs Custom Fields
In the REST APImetadata object:
| Field | Type | Description |
|---|---|---|
user_id | string | End user identifier |
thread_id | string | Conversation/session ID |
customer_id | string | Your tenant/customer ID |
labels | string[] | Categorization tags |
| other keys | any | Stored as custom metadata |
Timings
Beyond metadata, spans carry timing information that powers the latency views: the Duration column, the Time to First Token (TTFT) column, and the latency analytics.| Field | Where | Description |
|---|---|---|
timestamps.started_at | Span | When the operation started (epoch ms). Set automatically by the SDKs |
timestamps.first_token_at | Span | When the first streamed token arrived (epoch ms). Powers TTFT |
timestamps.finished_at | Span | When the operation finished (epoch ms). Set automatically by the SDKs |
gen_ai.server.time_to_first_token | OTEL attribute | TTFT as a duration in milliseconds, alternative to first_token_at |
- Python: Tracking Time to First Token
- TypeScript: Tracking Time to First Token
Best Practices
Always set user_id
Required for user-level analytics and filtering by specific users.
Use thread_id for conversations
Groups related messages together. Essential for chatbots and multi-turn interactions.
Labels for categorization
Use consistent labels like
production, staging, support for filtering.Custom metadata for context
Add any relevant context: feature flags, A/B variants, request sources.
What You Get
Once traces include metadata:- Filter by user: Find all traces for a specific user
- View conversations: See all messages in a thread grouped together
- Filter by labels: Quickly filter to specific categories
- Search custom fields: Find traces by any custom metadata value
- User analytics: View per-user metrics and patterns