Use this file to discover all available pages before exploring further.
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.
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.
Adding session.id to your spans enables back-and-forth interactions to be grouped. The session ID must be a non-empty string.
Python
JS/TS
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_sessionwith 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" ...
Use the setSession function with context.with to set the active context. OpenInference auto instrumentations will then pick up these attributes and add them to any spans created within the context.with callback.
import { context } from "@opentelemetry/api"import { setSession } from "@arizeai/openinference-core"context.with( setSession(context.active(), { sessionId: "session-id" }), () => { // Calls within this block will generate spans with the attributes: // "session.id" = "session-id" })
Often you’ll want to know who the session belongs to as well:
Adding user.id associates traces with a specific user. The user ID must be a non-empty string.
Python
JS/TS
Use using_user as a context manager to add user ID to the current OpenTelemetry Context.
from openinference.instrumentation import using_userwith 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" ...
Use the setUser function with context.with:
import { context } from "@opentelemetry/api"import { setUser } from "@arizeai/openinference-core"context.with( setUser(context.active(), { userId: "user-id" }), () => { // Calls within this block will generate spans with the attributes: // "user.id" = "user-id" })
Setting session and user one at a time works, but most apps need both. The using_attributes helper combines them:
from mistralai import Mistralfrom openinference.instrumentation import using_attributesclient = Mistral()with using_attributes( session_id="my-session-id", user_id="my-user-id",): response = client.chat.complete( model="mistral-large-latest", messages=[ {"content": "Who won the World Cup in 2018?", "role": "user"} ], )
import dspyfrom openinference.instrumentation import using_attributeslm = dspy.LM("openai/gpt-4o-mini")dspy.configure(lm=lm)class BasicQA(dspy.Signature): """Answer questions with short factoid answers.""" question = dspy.InputField() answer = dspy.OutputField(desc="often between 1 and 5 words")predictor = dspy.Predict(BasicQA)with using_attributes( session_id="my-session-id", user_id="my-user-id",): response = predictor( question="What is the capital of the united states?" )
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:
# 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.
Ask Alyx for help configuring sessions:
“How do I group traces into sessions?”
“Show me how to add session IDs with LangChain”
“What’s the best way to track user identity across traces?”
Now that sessions are in place, here’s what you’ll see in Arize AX:
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.