OllamaInstrumentor
traces native Ollama chat calls, including messages, responses, tool calls, and
token counts, as OpenInference LLM spans in Arize AX. Ollama also exposes an
OpenAI-compatible API, so
Node.js and Go applications can call it with the OpenAI SDK and trace it with
the OpenInference OpenAI instrumentation for
JavaScript / TypeScript
or Go.
Llama 3.2 + Ollama Tracing Tutorial (Google Colab)
Prerequisites
- Python 3.10+, Node.js 22+, or Go 1.25+
- An Arize AX account (sign up)
- Ollama installed and running locally
- The
llama3.2:1bmodel pulled:ollama pull llama3.2:1b
Launch Arize AX
- Sign in to your Arize AX account.
- From Space Settings, copy your Space ID and API Key. You will set them as
ARIZE_SPACE_IDandARIZE_API_KEYbelow.
Install
Configure credentials
ollama, which a local Ollama server ignores.
Setup tracing
ollama. In particular,
from ollama import chat captured before instrumentation is not traced. In
TypeScript, instrumentation.manuallyInstrument(OpenAI) must run before your
code creates an OpenAI client.
Run Ollama
Expected output
Verify in Arize AX
- Open your Arize AX space and select project
ollama-tracing-example. - You should see a new trace within ~30 seconds with an LLM span:
Chatfor the Python SDK,OpenAI Chat Completionsfor the Node.js SDK, oropenai.chat.completions.createfor the Go SDK. - If no traces appear, see Troubleshooting.
Check from the skill, CLI, or SDK
Confirm spans are actually reaching your Arize AX project. Use whichever fits your workflow — the skill and CLI work for any framework; the SDK check is shown for each language.- Arize skill (agent)
- AX CLI
- SDK
Install the Arize Skills plugin and let your coding agent check for you:Then prompt your agent:
Use the arize-trace skill to export and analyze recent traces from my project. Confirm spans are arriving, and summarize any errors or latency issues.
Troubleshooting
- No traces in Arize AX. Confirm
ARIZE_SPACE_IDandARIZE_API_KEYare set in the same shell that runs the example. In Python, runOllamaInstrumentor().instrument(...)before importing or callingollama. In TypeScript, make sure./instrumentationis the first import in your entry point. - Connection refused. Start the daemon with
ollama serveand confirm it responds athttp://localhost:11434. - Model not found. Pull it with
ollama pull llama3.2:1b. - No span for generate or embeddings (Python). This instrumentor traces chat only;
generate,embed, andembeddingscalls are not supported. - No span for embeddings (Go). The Go middleware instruments
/v1/chat/completions,/v1/responses, and/v1/decisions. Other endpoints pass through unchanged, and no span is emitted for them. - Go process exits before spans flush. The
defer tp.Shutdown(...)block inmain.goflushes the batched span processor. Without it, short-lived programs lose their last spans.