Microsoft Foundry
Export hosted agent traces to Confident AI with OpenTelemetry
Overview
Microsoft Foundry hosted agents run your agent application in a managed container. Configure the application's OpenTelemetry trace exporter to send agent, model, and tool spans to Confident AI.
Foundry provides an Application Insights connection string to hosted agents by default. To export to Confident AI, configure an OTLP exporter in the agent process. This guide covers agents whose application and telemetry setup you control.
Before You Begin
- A Foundry hosted agent with OpenTelemetry instrumentation.
- An OTLP/HTTP protobuf trace exporter installed in the agent container.
- A project API key from Confident AI.
- Outbound HTTPS access from the container to the Confident AI ingestion endpoint.
Configure Trace Export
Choose the agent's tracing setup
For Microsoft Agent Framework, initialize telemetry with its
configure_otel_providers()helper, which supports standard OTLP endpoint and header environment variables. Alternatively, use the framework's custom-exporter option with an explicitly configured OTLP trace exporter.If an existing library already owns the OpenTelemetry provider, attach the exporter to that provider and enable your framework's instrumentation. Avoid initializing competing global providers. See Microsoft's observability reference.
For another framework, use its native OpenTelemetry setup or the relevant Confident AI integration.
Configure the endpoint and credentials
Add these settings to your hosted agent's environment before telemetry initialization:
Setting Value OTEL_EXPORTER_OTLP_TRACES_ENDPOINThttps://otel.confident-ai.com/v1/tracesOTEL_EXPORTER_OTLP_TRACES_PROTOCOLhttp/protobufOTEL_EXPORTER_OTLP_TRACES_HEADERSx-confident-api-key=YOUR_CONFIDENT_PROJECT_KEYOTEL_SERVICE_NAMEA stable name for your hosted agent For an EU project, use
https://eu.otel.confident-ai.com/v1/traces. For a self-hosted deployment, use its full OTLP/HTTP traces URL. Supply your project key through your deployment's secret configuration.These are standard OTLP exporter settings. If your telemetry helper does not consume the signal-specific settings, configure the trace exporter explicitly with the same URL and header. See OpenTelemetry setup.
Use a trace exporter for this endpoint. Logs and metrics require their own destinations and must not be sent to
/v1/traces.Deploy and verify
Create and deploy an updated hosted-agent version with the telemetry configuration. Foundry environment variables are configured per agent version.
Invoke the deployed agent and open the Observatory in your Confident AI project. Verify that the agent's spans arrive, that parent/child relationships are preserved, and that the expected model and tool details are present. Flush pending spans during graceful shutdown.
What Gets Captured
The exported trace contains operations instrumented inside your hosted agent. Model names, token counts, tool arguments, and input/output content depend on the framework and its capture settings. See OpenTelemetry span attributes for the fields Confident AI recognizes.
Troubleshooting
- Traces appear only in Application Insights: confirm an OTLP trace exporter is initialized in addition to, or instead of, the Azure Monitor exporter.
- No traces: check instrumentation initialization, exporter configuration, outbound connectivity, and batch flushing.
- Authentication errors: check the project region and
x-confident-api-keyheader. - Missing message content: enable the framework's content capture where appropriate. Content emitted only as logs is not included by a trace exporter.
See Microsoft's hosted-agent documentation for deployment and default observability behavior.
Need help wiring this into your stack?Bring traces and evals into the tools your team already usesTalk to an expertLast updated on