Set up OpenTelemetry
To log Pydantic AI applications using Permitech, the first step is to set up OpenTelemetry.1
Install the required packages
Add the Permitech Python SDK and Pydantic AI to your Python environment.
2
Create environment variables for your Permitech settings
Set environment variables for your Permitech settings, for example in a
.env file:3
Get your endpoint
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/traceswill be used automatically. -
A self-hosted Permitech deployment, replace the
https://permi.tech/api/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.permitech.example.com, the OTel endpoint would behttps://api.permitech.example.com/otel/traces - if your console URL is
https://console-permitech.apps.mycompany.com, the OTel endpoint would behttps://api-permitech.apps.mycompany.com/otel/traces
4
Configure the OpenTelemetry tracer provider
Use the following code to configure OpenTelemetry with Permitech. This sets up the tracer provider and enables instrumentation for all Pydantic AI agents.
Python
What gets logged
Pydantic AI spans are automatically detected and normalized by Permitech’s OpenTelemetry extension. The following span types are supported:- Agent runs: Complete agent executions with input/output messages
- Chat completions: LLM calls with messages and responses
- Tool executions: Individual tool invocations with arguments and results
- Tool workflows: Parent spans that group multiple tool executions

