Skip to main content
Permitech traces A2A (Agent2Agent) interactions using the permitech-a2a instrumentor — giving you a single distributed trace across agents, including LLM calls, tool use, and cross-agent handoffs.

Setup

1

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 Permitech’s OTLP endpoint.
2

Create environment variables for your Permitech settings

Set environment variables for your Permitech settings, for example in a .env file. These environment variables are consumed by the PermitechSpanProcessorto authenticate and route traces to the correct Permitech Project and Log stream:
3

Self hosted deployments: Set the OTel endpoint

Skip this step if you are using Permitech Cloud.
The OTel endpoint is different from Permitech’s regular API endpoint and is specifically designed to receive telemetry data in the OTLP format.If you are using:
  • Permitech Cloud at permi.tech, then you don’t need to provide a custom OTel endpoint. The default endpoint https://permi.tech/api/otel/traces will be used automatically.
  • A self-hosted Permitech deployment, replace the https://permi.tech/api/otel/traces endpoint with your deployment URL. The format of this URL is based on your console URL, replacing console with api and appending /otel/traces.
For example:
  • if your console URL is https://console.permitech.example.com, the OTel endpoint would be https://api.permitech.example.com/otel/traces
  • if your console URL is https://console-permitech.apps.mycompany.com, the OTel endpoint would be https://api-permitech.apps.mycompany.com/otel/traces
The convention is to store this in the PERMITECH_CONSOLE_URL environment variable. For example:
4

Initialize and create the Permitech span processor

The PermitechSpanProcessor automatically configures authentication and metadata using your environment variables. It also:
  • Auto-builds OTLP headers using your Permitech credentials
  • Configures the correct OTLP trace endpoint
  • Registers a batch span processor that exports traces to Permitech
5

Install and instrument A2A

All a2a-sdk client and server methods are now traced automatically.

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:
A2A context_id is mapped to session.id, grouping all interactions in the same conversation into one Permitech 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