What is a session?
A session is a container for one or more traces. All spans within a session share the samesessionId, enabling you to:
- Track multi-step workflows across multiple API calls
- Analyze user behavior across multiple interactions
- Monitor batch processing jobs
- Debug conversation flows in chatbots
Session structure
Each session has:- Session ID: A unique UUID identifying the session
- Session name: An optional human-readable name
- Session tags: Tags applied to all traces in the session
Creating sessions
Automatic session creation
When you create a root span without specifying a session, one is automatically generated:Explicit session creation
You can explicitly set the session ID and name:Using existing sessions
Multiple root traces can share the same session by using the samesessionId:
Session inheritance
Child spans automatically inherit the session from their parent:Session tags
You can add tags that apply to all spans in a session:Session signals
You can send signals that apply to an entire session:Common use cases
User sessions
Track a user’s activity across multiple API requests:Batch processing
Track a batch job that processes multiple items:Conversation threads
Track a chatbot conversation across multiple turns:Best practices
Use consistent session IDs
Use consistent session IDs
Generate session IDs consistently for the same logical unit:
Set meaningful session names
Set meaningful session names
Use descriptive names that indicate the purpose:
Add session tags for filtering
Add session tags for filtering
Use session signals for metrics
Use session signals for metrics
Track aggregate metrics at the session level:
Keep sessions focused
Keep sessions focused
Don’t make sessions too broad or too narrow: