arize-otel exporter to send its traces to Arize AX.
Overview
In this guide, you will learn how to attach the OpenInference Groq instrumentor and thearize-otel exporter to a Groq agent, run the agent, and read the resulting trace tree in Arize AX. The agent calls Groq’s chat completions endpoint, its general-purpose interface for text generation. This setup applies to any Groq agent, whether you run it as a script, inside a web service such as FastAPI, or as a background worker.
This guide assumes you have familiarity with:
- Python
- The Groq chat completions API and the tool-use loop (
chat.completions.create,tool_calls,role: "tool"messages) - Environment variables and package installation
- Auto-instrument Groq SDK calls so each model request is captured as an LLM span
- Add manual AGENT and TOOL spans so the loop and tool executions appear in the trace
- Group traces by conversation using session IDs
- Verify and read the full agent trace tree in Arize AX
Before you start
You need:- An existing agent built with Groq
- An Arize AX account (sign up)
- A
GROQ_API_KEYfrom the Groq Console - Python 3.10 or later
Get your Arize AX credentials
Sign in to your Arize AX account and create a tracing project from Projects → New Tracing Project. The setup page shows the credentials you need: copy your Space ID, then click Create API Key to generate a key and save it somewhere safe. You set them asARIZE_SPACE_ID and ARIZE_API_KEY when you configure your environment below, and they route your traces to the correct space.

1
Install dependencies
Install the Groq instrumentor, the OpenInference helpers for manual spans, and the
groq SDK.2
Configure credentials
Set your Arize AX and Groq credentials as environment variables. The tracing setup reads them at startup.
ARIZE_PROJECT_NAME is the project your traces land in. Name it for the app so runs stay grouped where you expect them.3
Auto-instrument the Groq SDK
Set up tracing in a dedicated module so it runs once, before your agent uses the SDK. This registers a tracer provider with your Arize credentials and attaches the Groq instrumentor, which captures every
chat.completions.create call as an LLM span.instrumentation.py
4
Trace the agent loop
In the example below, the tool definition,
run_tool, and the while loop are ordinary Groq agent code. The instrumentation is the tracer and the two start_as_current_span blocks that wrap the loop in an AGENT span and each tool execution in a TOOL span. The chat.completions.create calls inside the AGENT span are auto-instrumented, so they nest underneath it as LLM spans. The OpenInference attributes are set as string keys ("openinference.span.kind", "input.value").5
Group traces by conversation
To follow a multi-turn conversation as a single thread, tag its runs with a shared session ID that is stable across the conversation, such as the user or thread ID. Wrapping the body of Arize AX groups the tagged runs together, so you can replay a full conversation.
handle_turn in the using_session() context manager is the only change; every span emitted inside, manual and auto, then carries the same session.id.6
Verify in Arize AX
Open your Arize AX space and select the project you set in
ARIZE_PROJECT_NAME. Within about 30 seconds of a run, a new trace appears with this shape:- An AGENT root span (
nutrition-agent) carrying the user input and final answer. - One or more LLM child spans, one per
chat.completions.createcall, with the prompt, response, model name, and token counts filled in automatically by the Groq instrumentor. - A TOOL child span for each tool the agent ran, with the tool inputs and outputs.
What gets captured
The two layers combine into one trace:- LLM spans (automatic). The Groq instrumentor records each
chat.completions.createcall: prompt, response, thetool_callsthe model emits, the model name, and token usage. - AGENT and TOOL spans (manual). Your spans record the loop as a whole and each tool execution, so the trace shows what the agent decided to do and what each tool returned, not just the raw model calls.
- Session grouping. The
session.idyou set threads related runs into one conversation.
chat.completions.create calls run inside it.
Groq’s compound models (
groq/compound and groq/compound-mini) run built-in tools such as web search and code execution on Groq’s own infrastructure. Those executions happen server-side, so the instrumentor cannot break them out into separate TOOL spans. They are captured as part of the LLM span for the call. Client-side tools that you execute in your own loop, as shown above, are what produce distinct TOOL spans.Troubleshooting
- No traces in Arize AX. Confirm
ARIZE_SPACE_IDandARIZE_API_KEYare set in the same shell that runs your app. Enable OpenTelemetry debug logs withexport OTEL_LOG_LEVEL=debugand rerun. - LLM spans missing.
GroqInstrumentor().instrument(...)must run before the firstchat.completions.createcall. Import the tracing module first. - LLM spans not nested under the agent span. The
chat.completions.createcall must run inside the active AGENT span. Keep it inside thewith tracer.start_as_current_span(...)block. 401or404from Groq. VerifyGROQ_API_KEYis set and valid, and that the model in the example is available to your account. Swapllama-3.3-70b-versatilefor another supported model if needed.- A short-lived script exports nothing. Spans are batched by default, so a script that exits right after the run can quit before they flush. Call
tracer_provider.force_flush()before the process exits. Long-running apps and servers flush on their own. wrap_function_wrapper() got an unexpected keyword argument 'module'. Awrapt2.x release changed that function’s signature, which older instrumentor pins do not yet account for. Pinwraptbelow 2 until the pins catch up:pip install "wrapt<2".
Next steps
Combine auto and manual
The general pattern for mixing auto LLM spans with manual spans.
Agent trajectory
Render the agent’s execution as an interactive graph.
Set up sessions
Group multi-turn runs into conversations with session and user IDs.
Anthropic SDK agents
The same auto-plus-manual pattern for an agent built on the Anthropic SDK.