What is Tracing?
Tracing records the execution path of your LLM application by creating spans—individual units of work that represent operations like:- LLM generation calls
- Retrieval operations
- Tool/function invocations
- Chain executions
- Embeddings generation
How It Works
Phoenix implements the OpenTelemetry standard with semantic conventions specifically designed for LLM applications through the OpenInference specification.Automatic Instrumentation
Phoenix provides automatic instrumentation for popular LLM frameworks with zero code changes:OpenAI
Automatically trace all OpenAI API calls
LangChain
Capture chain execution and component interactions
LlamaIndex
Trace queries, retrievals, and index operations
Anthropic
Monitor Claude API interactions
Span Hierarchy
Spans are organized in a tree structure based on thetrace_id and parent_id attributes defined in /home/daytona/workspace/source/src/phoenix/trace/attributes.py. Each span contains:
- Context:
span_id,trace_idfor linking spans together - Timing:
start_time,end_timefor performance analysis - Metadata:
name,span_kind,status_codefor categorization - Attributes: Nested key-value pairs with LLM-specific data
Span Attributes
Phoenix uses a sophisticated attribute system (implemented insrc/phoenix/trace/attributes.py) that supports:
Flattened Keys: Dot-separated paths like llm.token_count.completion are automatically unflattened into nested structures:
Projects and Sessions
Phoenix organizes traces using projects and sessions:Projects
Projects group related traces together. Set the project name via theResourceAttributes.PROJECT_NAME attribute:
using_project context manager (from src/phoenix/trace/projects.py):
The
using_project context manager is deprecated and has been moved to openinference-instrumentation. Use it only in notebook environments for quick experimentation.Sessions
Sessions group traces within a project, typically representing a single user interaction or conversation thread. Sessions are identified by metadata attributes added to spans.Key Features
Rich Metadata
Capture comprehensive details about each operation:- LLM calls: Model name, token counts, prompts, completions, parameters
- Retrievals: Documents, scores, queries
- Tools: Function names, parameters, results
- Errors: Stack traces and error messages
Performance Insights
Analyze latency at every level:- Total trace duration
- Individual span timings
- Time spent in LLM calls vs. retrieval vs. processing
Evaluation Integration
Traces can be evaluated using the evaluation system (see Evaluation). Attach evaluations directly to spans:Working with Traces
Export Traces
Export traces to datasets for offline analysis using theTraceDataset class (from src/phoenix/trace/trace_dataset.py):
Create Datasets from Traces
Convert production traces into evaluation datasets (see Datasets):Query Traces
Access trace data programmatically via the Phoenix client:Suppressing Tracing
Temporarily disable tracing for specific code sections usingsuppress_tracing (from openinference.instrumentation):
Next Steps
Evaluation
Learn how to evaluate traced spans with LLM judges
Datasets
Create versioned datasets from your traces
Experiments
Run systematic experiments on your LLM application
Instrumentation Guide
Detailed instrumentation setup for all frameworks