Tracing capabilities for Azure AI Foundry.
Disable callback manager auto-tracing and restore original behavior.
Enable auto-injection of Azure tracer into callback managers.
When called, every new BaseCallbackManager instance and every callback
manager created through LangGraph's helper factories will automatically
include an AzureAIOpenTelemetryTracer in its inheritable handlers.
Each parameter falls back to an environment variable when not supplied:
APPLICATION_INSIGHTS_CONNECTION_STRINGAZURE_TRACING_GEN_AI_CONTENT_RECORDING_ENABLEDAZURE_AI_PROJECT_ENDPOINT (or
FOUNDRY_PROJECT_ENDPOINT when the former is not set)AZURE_TRACING_PROVIDER_NAMEAZURE_TRACING_AGENT_IDAZURE_TRACING_ALL_LANGGRAPH_NODESOTEL_MESSAGE_KEYS (comma-separated)OTEL_MESSAGE_PATHS (comma-separated)OTEL_AUTO_CONFIGURE_AZURE_MONITOROTEL_TRACE_LANGGRAPH_STATEOTEL_MAX_STATE_SIZEReturn whether auto-tracing monkey patch is currently enabled.
OpenTelemetry instrumentor implementation for LangChain auto-tracing.
LangChain callback handler that emits OpenTelemetry GenAI spans.
OpenTelemetry tracer for LangChain/LangGraph inference aligned with GenAI spec.
This implementation emits spans for agent execution, model invocations, tool calls, and retriever activity and records attributes in line with the OpenTelemetry GenAI semantic conventions. It supports simultaneous export to Azure Monitor (when a connection string is supplied) and to any OTLP collector configured via environment variables (for example::
export OTEL_EXPORTER_OTLP_ENDPOINT=http://localhost:4317
export OTEL_EXPORTER_OTLP_PROTOCOL=grpc
The tracer focuses on three design goals:
The module exports the AzureAIOpenTelemetryTracer callback handler. Attach
an instance to LangChain run configs (for example in config["callbacks"])
to instrument your applications.
Auto-instrumentation helpers for LangChain/LangGraph tracing.