Set up OpenTelemetry
To log Microsoft Agent Framework traces using Permitech, the first step is to set up OpenTelemetry.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.
-
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
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
Log a Microsoft Agent Framework agent using OpenTelemetry
Once OpenTelemetry is configured, you can use thePermitechSpanProcessor to capture traces from your agent.
1
Create the tracer provider with the Permitech span processor
Set up a
TracerProvider with the PermitechSpanProcessor and register it as the global tracer provider:2
Enable the framework's instrumentation
Enable the Microsoft Agent Framework’s built-in OTel instrumentation. Set When you run your agent code, traces will be logged to Permitech.
enable_sensitive_data=True to send LLM inputs and outputs to Permitech. If set to False, only span metadata (timing, token counts, etc.) will be sent.Full example
Here is a full example based on the Microsoft Agent Framework’s tool calling sample. You can find this project in the . To run this example, create a.env file with the following values set, or set them as environment variables:
.env

