Metadata and attributes are key-value pairs that allow you to add custom contextual information to your traces and spans. This enrichment is invaluable for debugging, analysis, filtering, and gaining deeper insights into your LLM application’s behavior. In the TypeScript SDK, all metadata is captured through span attributes. You can set attributes on any span to provide context for that operation or the entire trace.Documentation Index
Fetch the complete documentation index at: https://langwatch.ai/docs/llms.txt
Use this file to discover all available pages before exploring further.
For a comprehensive reference of all available attributes and semantic conventions, see the Semantic Conventions guide.
Setting Attributes
UsesetAttributes() on any span to attach metadata. For trace-level context, set attributes on the root span:
Common Attributes
- User and session:
langwatch.user.id,langwatch.thread.id- see Tracking Conversations - Application context:
app.version,environment,region - LLM operations:
gen_ai.request.model,gen_ai.request.temperature - Custom business logic:
customer.tier,feature.flags
Setting Attributes on Child Spans
You can set attributes on any span in your trace hierarchy:Adding Labels to Traces
Labels allow you to organize, filter, and categorize your traces in the LangWatch dashboard:Viewing in LangWatch
All captured span attributes will be visible in the LangWatch UI:- Root span attributes are displayed in the trace details view, providing an overview of the entire operation
- Child span attributes are shown when you inspect individual spans within a trace
- Filter and search for traces and spans based on specific attribute values
- Analyze performance by correlating metrics with different attributes
- Debug issues by quickly understanding the context and parameters of a failed or slow operation