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.
Semantic convention attribute names used throughout the tracer.
Attributes sourced from the OpenTelemetry GenAI semantic conventions SDK
(opentelemetry.semconv._incubating.attributes.gen_ai_attributes).
Custom attributes not yet in the SDK are defined inline.
LangChain callback handler that emits OpenTelemetry GenAI spans.