Overview
This guide shows you how to send traces from a Pydantic AI agent to Latitude. Pydantic AI has OpenTelemetry support built in. CallingAgent.instrument_all() makes it emit standard gen_ai.* spans for every agent run, model call, and tool execution. Latitude’s Python SDK registers the global OpenTelemetry provider those spans flow into, so you get full traces without a dedicated instrumentor — Latitude reads Pydantic AI’s native spans directly.
You’ll keep building Pydantic AI agents exactly as you do today. Latitude only
adds the export path for the spans Pydantic AI already emits.
The Pydantic AI integration is Python only.
Requirements
- A Latitude account and API key
- A Latitude project slug
- A Python project that uses Pydantic AI (
pydantic-ai)
Steps
Initialize Latitude and enable instrumentation
Initialize Latitude once at startup, then turn on Pydantic AI’s OpenTelemetry instrumentation. You do not need an
instrumentations entry for Pydantic AI, because it emits OpenTelemetry spans itself.The SDK registers
atexit and signal shutdown handlers automatically. The
explicit latitude.shutdown() is a safeguard for short-lived scripts and
notebooks, ensuring buffered spans flush before the process exits.Bring your own OpenTelemetry
If your app already runs its own OpenTelemetryTracerProvider, skip the Latitude SDK and point that provider’s OTLP exporter at Latitude, then still call Agent.instrument_all():
OTEL_EXPORTER_OTLP_ENDPOINT is the base URL — the OpenTelemetry SDK
appends /v1/traces automatically. Do not include the path yourself or traces
will fail to reach Latitude. The full endpoint
https://ingest.latitude.so/v1/traces is what you use with curl or the
signal-specific OTEL_EXPORTER_OTLP_TRACES_ENDPOINT.What you get
Each agent run shows up as a trace with nested spans:- Agent spans — the agent run, its user message, and the final response
- Model spans — model invocations with input/output messages, model name, and token usage
- Tool spans — tool name, input arguments, and output result
gen_ai.* attributes (OpenTelemetry GenAI semantic conventions), Latitude renders model name, token counts, and messages automatically.
Seeing Your Traces
Once connected, traces appear automatically in Latitude:- Open your project in the Latitude dashboard
- Run your agent with at least one model call or tool call
- Confirm the agent → model → tool hierarchy appears with model metadata, token usage, and latency