galileo-a2a instrumentor — giving you a single distributed trace across agents, including LLM calls, tool use, and cross-agent handoffs.
Setup
Installation
Add the OpenTelemetry packages to your project:The
opentelemetry-api and opentelemetry-sdk packages provide the core OpenTelemetry functionality. The opentelemetry-exporter-otlp package enables sending traces to Galileo’s OTLP endpoint.Create environment variables for your Galileo settings
Set environment variables for your Galileo settings, for example in a
.env file.
These environment variables are consumed by the GalileoSpanProcessorto authenticate
and route traces to the correct Galileo Project and Log stream:Self hosted deployments: Set the OTel endpoint
Skip this step if you are using Galileo Cloud.
-
Galileo Cloud at app.galileo.ai, then you don’t need to provide a custom OTel endpoint.
The default endpoint
https://api.galileo.ai/otel/traceswill be used automatically. -
A self-hosted Galileo deployment, replace the
https://api.galileo.ai/otel/tracesendpoint with your deployment URL. The format of this URL is based on your console URL, replacingconsolewithapiand appending/otel/traces.
- if your console URL is
https://console.galileo.example.com, the OTel endpoint would behttps://api.galileo.example.com/otel/traces - if your console URL is
https://console-galileo.apps.mycompany.com, the OTel endpoint would behttps://api-galileo.apps.mycompany.com/otel/traces
GALILEO_CONSOLE_URL environment variable. For example:Initialize and create the Galileo span processor
The
GalileoSpanProcessor automatically configures authentication
and metadata using your environment variables. It also:- Auto-builds OTLP headers using your Galileo credentials
- Configures the correct OTLP trace endpoint
- Registers a batch span processor that exports traces to Galileo
How it works
When Agent A calls Agent B, trace context is propagated through A2A message metadata. Both agents’ spans appear in one distributed trace:context_id is mapped to session.id, grouping all interactions in the same conversation into one Galileo session.
Full example
Two LangGraph agents in one script. Agent A (orchestrator) plans, delegates to Agent B via A2A, then synthesizes. Agent B (researcher) uses a tool and LLM to answer. Copy-paste and run..env