Skip to main content
Conversations, not one-offs. Real users have multi-turn interactions where context across turns matters — sessions group those traces together so you can see the full conversation as a single unit.

What are Sessions?

A session is a grouping of related traces. In a chatbot, each turn generates its own trace. Tag them with the same session.id and you can view the full conversation as one unit — spot where things went wrong across turns, identify when users become frustrated, and run session-level evaluations. Arize AX tracks per session: duration, trace count, total prompt tokens, total completion tokens, and total tokens.
Sessions view in Arize AX showing session duration, trace count, and token usage

Add Session ID

Adding session.id to your spans enables back-and-forth interactions to be grouped. The session ID must be a non-empty string.
Use using_session as a context manager to add session ID to the current OpenTelemetry Context. OpenInference auto instrumentors will read this Context and pass the session ID as a span attribute, following the OpenInference semantic conventions.
from openinference.instrumentation import using_session

with using_session(session_id="my-session-id"):
    # Calls within this block will generate spans with the attributes:
    # "session.id" = "my-session-id"
    ...
It can also be used as a decorator:
@using_session(session_id="my-session-id")
def call_fn(*args, **kwargs):
    # Calls within this function will generate spans with the attributes:
    # "session.id" = "my-session-id"
    ...
Often you’ll want to know who the session belongs to as well:

Add User ID

Adding user.id associates traces with a specific user. The user ID must be a non-empty string.
Use using_user as a context manager to add user ID to the current OpenTelemetry Context.
from openinference.instrumentation import using_user

with using_user("my-user-id"):
    # Calls within this block will generate spans with the attributes:
    # "user.id" = "my-user-id"
    ...
It can also be used as a decorator:
@using_user("my-user-id")
def call_fn(*args, **kwargs):
    # Calls within this function will generate spans with the attributes:
    # "user.id" = "my-user-id"
    ...
Setting session and user one at a time works, but most apps need both. The using_attributes helper combines them:

Framework-Specific Examples

Use using_attributes to set session and user IDs together with any supported framework.
Requires pip install openinference-instrumentation-openai
import openai
from openinference.instrumentation import using_attributes

client = openai.OpenAI()

# Set session and user together
with using_attributes(
    session_id="my-session-id",
    user_id="my-user-id",
):
    response = client.chat.completions.create(
        model="gpt-4o",
        messages=[{"role": "user", "content": "Write a haiku."}],
        max_tokens=20,
    )
Can also be used as a decorator:
@using_attributes(session_id="my-session-id", user_id="my-user-id")
def call_fn(client, *args, **kwargs):
    return client.chat.completions.create(*args, **kwargs)
Once sessions are wired up in your code, you can verify them in the Arize AX UI — but first, if you’d rather not write the code:

Other Ways to Set Up

Sessions can also be added through an AI coding agent using the Arize instrumentation skill, or through Alyx in the Arize AX UI.
Three steps to add sessions with your AI coding agent:Install skill
npx skills add Arize-ai/arize-skills --skill "arize-instrumentation" --yes
Set up authentication
export ARIZE_API_KEY="YOUR_API_KEY"
export ARIZE_SPACE_ID="YOUR_SPACE_ID"
Add sessions
# Ask your AI coding agent:
"Add session ID and user ID tracking to my app"
Works with Cursor, Claude Code, Codex, and more. The skill picks the right framework helper (using_session / setSession) and wires it into the right spots.
Now that sessions are in place, here’s what you’ll see in Arize AX:

View Sessions

Once your traces have session IDs attached, head to your project in Arize AX and switch to the Sessions view. You’ll see each session as a row — click into one to see the full multi-turn conversation with all its traces laid out in order. For each session, Arize AX shows you:
  • Duration — how long the conversation lasted
  • Trace count — how many turns/requests were in the session
  • Token usage — total prompt, completion, and combined tokens across all traces
This makes it easy to find long, expensive, or problematic conversations and drill into exactly where things went wrong.
Session detail view in Arize AX showing total duration, token count, trace list with evals, session coherence evaluation, and a session conversation JSON pane

Next step

Sessions are set up. Learn how to combine auto and manual instrumentation for complete trace coverage:

Next: Combine Auto + Manual