Semantic Conventions
This guide covers OpenTelemetry semantic conventions and how LangWatch implements them, along with our custom attributes for LLM-specific observability.OpenTelemetry Standards
Understand the OpenTelemetry semantic conventions that LangWatch follows for consistent observability.
LangWatch Attributes
Explore LangWatch’s custom attributes designed specifically for LLM applications and AI observability.
What Are Semantic Conventions?
Semantic conventions are standardized naming and structure guidelines for observability data. They ensure consistency across different systems and make it easier to analyze and correlate data from various sources.OpenTelemetry semantic conventions provide a standardized way to name attributes, events, and other observability data, making it easier to build tools and dashboards that work across different applications and services. For practical examples of these conventions in action, see Manual Instrumentation.
Benefits of Semantic Conventions
- Consistency: Standardized naming across all your services
- Interoperability: Works with any OpenTelemetry-compatible tool
- Analytics: Easier to build dashboards and alerts
- Debugging: Familiar patterns make troubleshooting faster
- Team Collaboration: Shared understanding of observability data
OpenTelemetry Semantic Conventions
LangWatch fully implements OpenTelemetry semantic conventions, ensuring your traces are compatible with any OpenTelemetry-compatible observability platform.Core Semantic Conventions
The OpenTelemetry specification defines conventions for common observability scenarios. LangWatch supports all OpenTelemetry semantic conventions while also providing its own custom attributes for LLM-specific observability.Span Types and Attributes
OpenTelemetry defines standard span types and their associated attributes. LangWatch extends these with custom span types for LLM operations:TypeScript Autocomplete Support
All attribute setting methods in LangWatch provide full TypeScript autocomplete support, you don’t need to import anything, just use the attribute names directly and autocomplete will appear in your editor.Autocomplete in Span Methods
Autocomplete in Configuration
LangWatch Attributes Reference
LangWatch provides a comprehensive set of custom attributes for LLM-specific observability. All attributes are available with TypeScript autocomplete support.Core LangWatch Attributes
Attribute | Type | Description | Example |
---|---|---|---|
langwatch.span.type | string | Type of span being traced | "llm" , "rag" , "prompt" |
langwatch.user.id | string | User identifier | "user-123" |
langwatch.thread.id | string | Conversation thread identifier | "thread-456" |
langwatch.customer.id | string | Customer identifier | "customer-789" |
langwatch.streaming | boolean | Whether the operation involves streaming | true , false |
langwatch.input | string/object | Input data for the span | "Hello, how are you?" |
langwatch.output | string/object | Output data from the span | "I'm doing well, thank you!" |
langwatch.contexts | array | RAG contexts for retrieval-augmented generation | Array of document contexts |
langwatch.tags | array | Tags for categorizing spans | ["chat", "greeting"] |
langwatch.params | object | Parameter data for operations | { temperature: 0.7 } |
langwatch.metrics | object | Custom metrics data | { response_time: 1250 } |
langwatch.timestamps | object | Timing information for events | { start: 1234567890 } |
langwatch.evaluation.custom | object | Custom evaluation data | { score: 0.95 } |
SDK Information Attributes
Attribute | Type | Description | Example |
---|---|---|---|
langwatch.sdk.name | string | LangWatch SDK implementation name | "langwatch-typescript" |
langwatch.sdk.version | string | Version of the LangWatch SDK | "1.0.0" |
langwatch.sdk.language | string | Programming language of the SDK | "typescript" |
Prompt Management Attributes
Attribute | Type | Description | Example |
---|---|---|---|
langwatch.prompt.id | string | Unique prompt identifier | "prompt-123" |
langwatch.prompt.handle | string | Human-readable prompt handle | "customer-support-greeting" |
langwatch.prompt.version.id | string | Prompt version identifier | "version-456" |
langwatch.prompt.version.number | number | Prompt version number | 2 |
langwatch.prompt.selected.id | string | Selected prompt from a set | "selected-prompt-789" |
langwatch.prompt.variables | object | Variables used in prompt templates | { customer_name: "John" } |
LangChain Integration Attributes
Attribute | Type | Description | Example |
---|---|---|---|
langwatch.langchain.run.id | string | LangChain run identifier | "run-123" |
langwatch.langchain.run.type | string | Type of LangChain run | "chain" , "tool" |
langwatch.langchain.run.parent.id | string | Parent run identifier | "parent-run-456" |
langwatch.langchain.event_name | string | LangChain event type | "chain_start" |
langwatch.langchain.run.metadata | object | Run metadata | { model: "gpt-5-mini" } |
langwatch.langchain.run.extra_params | object | Additional run parameters | { max_tokens: 1000 } |
langwatch.langchain.run.tags | array | Run-specific tags | ["production", "chain"] |
langwatch.langchain.tags | array | LangChain operation tags | ["langchain", "llm"] |
Best Practices
Attribute Naming
Follow these conventions for consistent observability:Attribute Values
Use appropriate data types and formats:Sensitive Data
Never include sensitive information in attributes:Performance Considerations
Limit the number and size of attributes for performance:✅ Good | ❌ Avoid | Reason |
---|---|---|
4-8 attributes per span | 50+ attributes | Too many impacts performance |
Short string values | Large text content | Use span.setInput() for large content |
Structured data | Nested objects | Keep attributes simple |
Essential metadata | Redundant information | Only include what’s needed |
Summary
Semantic conventions provide a standardized approach to observability data that:- Ensures consistency across your entire application
- Enables interoperability with OpenTelemetry-compatible tools
- Improves debugging with familiar patterns
- Supports team collaboration with shared understanding
Key takeaways:
- Use semantic convention attributes for consistency
- Import
attributes
from LangWatch for autocomplete - Follow OpenTelemetry standards for interoperability
- Leverage LangWatch’s LLM-specific attributes for AI observability
Related Documentation
For practical examples and advanced usage patterns:- Integration Guide - Basic setup and core concepts
- Manual Instrumentation - Practical examples of semantic conventions in action
- API Reference - Complete API documentation with attribute details
- Framework Integrations - Framework-specific semantic conventions
- Capturing RAG - RAG-specific attributes and conventions
Use semantic conventions consistently across your application for better analytics, debugging, and team collaboration. Start with the Manual Instrumentation tutorial to see these conventions in practice.