Skip to main content
Sessions provide automatic span linking for multi-turn conversations. Each call in a session is automatically connected to previous calls, making it easy to visualize conversation flows in the Tracia dashboard.

Creating a Session

Basic Usage

How It Works

When you use a session:
  1. First call - A trace ID is generated to group all spans in this session
  2. Subsequent calls - Automatically include:
    • traceId: The session’s trace ID (groups all spans together)
    • parentSpanId: The previous span’s ID (creates a chain)
This creates a tree structure in the Tracia dashboard where you can see the full conversation flow.

TraciaSession Methods

runLocal()

Same as tracia.runLocal() but with automatic span linking:

runResponses()

Same as tracia.runResponses() but with automatic span linking:

getTraceId()

Returns the session’s trace ID (groups all spans):

getLastSpanId()

Returns the most recent span ID:

reset()

Clears session state to start a new trace:

Continuing Existing Traces

Use createSession with a traceId to continue a trace across requests or services:

Manual Span Linking

If you prefer manual control, you can use traceId and parentSpanId directly:

Streaming with Sessions

Sessions work with streaming:

Use Cases

  • Chat applications: Track full conversation threads
  • Multi-step agents: Link planning, execution, and verification steps
  • RAG pipelines: Connect retrieval and generation spans
  • Debugging: Easily find all spans related to a user session