Skill 4.2.1
Trace distributed systems by using OpenTelemetry SDKs
Key Concepts
OpenTelemetry defines traces, metrics and logs and the SDKs that produce them. A trace is a tree of spans; each span has a name, start and end time, attributes, events, a status and the trace ID it shares with its parent. Context propagation carries the trace ID and parent span ID between services in the W3C traceparent header or in message properties, so that spans from different processes join one trace.
For Python, the Azure Monitor distro configures OpenTelemetry in one call, enables instrumentations for libraries such as requests, Flask, FastAPI, Django and psycopg2, and exports to Application Insights using APPLICATIONINSIGHTS_CONNECTION_STRING. Existing apps use configure_azure_monitor() from azure-monitor-opentelemetry; Microsoft now recommends the Microsoft OpenTelemetry Distro, use_microsoft_opentelemetry(), for new apps. Code adds custom spans with tracer.start_as_current_span(), and OTEL_SERVICE_NAME sets the cloud role name.