Domain 4 of 4 · Chapter 3 of 4

Trace distributed systems with OpenTelemetry

Unlock the complete study guide + 1,040 practice questions across 16 full exams.

Bundled into the existing Developing AI Cloud Solutions on Azure premium course — no separate purchase.

14-day money-back guarantee — no questions asked.

Included in this chapter:

  • From a unit of work to a row you can query
  • A span on the wire, a request in the portal
  • Distro, SDK, exporter, instrumentation library
  • Two ways to instrument without writing a span
  • Writing your own spans, and reporting your own errors
  • Four places to cut volume, and they multiply
  • A sampler built to keep traces whole
  • Live Metrics, the channel that never reaches a table
  • When the dashboard says success and the caller says failure
  • Telling the traps apart

Three ways to get Python telemetry into Application Insights

QuestionApp Service autoinstrumentationIn-code distroExporter on your own TracerProvider
How it is turned onApp settings only: connection string plus the agent extension version. No code change.configure_azure_monitor() called once at startup, in your own code.You build a TracerProvider, add a BatchSpanProcessor wrapping AzureMonitorTraceExporter, and register it.
Where it runsLinux App Service apps deployed as code. Custom containers are not supported.Anywhere your Python process runs.Anywhere your Python process runs.
Which libraries it instrumentsDjango, FastAPI, Flask, psycopg2, requests, urllib, urllib3, plus community packages you add to requirements.txt.The same bundled set, each individually switchable by name.Nothing until you add instrumentation libraries yourself.
LoggingCollects from the root logger.logger_name selects the namespace, which keeps SDK logs out of your telemetry.You wire the log pipeline yourself, or send no logs.
Live MetricsNot available.Enabled by default.Not part of the exporter; the Azure Monitor sampler is required for compatibility.
Entra authenticated ingestionOn the published unsupported list for Python on App Service.Supported.Supported through the exporter's credential option.
SamplerConfigured through OTEL_TRACES_SAMPLER_ARG as an app setting.sampling_ratio or traces_per_second, or the OTEL_TRACES_SAMPLER pair.Yours to add. The exporter's own documentation states the Application Insights sampler must be used whenever the exporter is.

Decision tree

Can you change theapplication code?noApp Service autoinstrumentationLinux, deploy as code, no Live Metrics, no Entra ingestionyesMust you own theTracerProvider yourself?noIn-code distro: configure_azure_monitor()the default answer for anything you can deployyesStill need Live Metrics orbundled instrumentation?yesDistro with span_processors=[...]custom processing without giving up the distronoExporter on your own TracerProvideryou must add ApplicationInsightsSampler yourself

Cheat sheet

  • configure_azure_monitor() wires OpenTelemetry export to Application Insights in one call
  • The exporter can be attached to a manually built TracerProvider
  • Individual bundled instrumentations are switched off by name
  • Ingestion volume is throttled by the Distro's sampler arguments
  • Live Metrics streams unsampled, unstored, unbilled telemetry over a two-way channel
  • Telemetry volume is cut at the SDK or at ingestion, and the two act at different points
  • App Service autoinstrumentation and the in-code Distro have different ceilings
  • A trace is a tree of spans sharing a trace ID, propagated across services by the traceparent header
  • Manual spans add custom operations and attributes inside the current trace
  • The Distro auto-instruments common libraries so calls are traced without code changes
  • OpenTelemetry is a vendor-neutral standard; the Azure Monitor Distro packages it with an exporter
  • Never call instrument() for a library the Distro already covers
  • An exception you catch yourself is invisible unless you record it on the span
  • Exported spans become requests and dependencies correlated by a shared operation ID
  • Sampling reduces telemetry volume while keeping whole traces intact

Unlock with Premium — includes all practice exams and the complete study guide.

Also tested in

References

  1. OpenTelemetry traces
  2. Add and modify OpenTelemetry in Application Insights
  3. Telemetry correlation in Application Insights
  4. OpenTelemetry context propagation
  5. Migrate to workspace-based Application Insights resources
  6. OpenTelemetry distributions
  7. Enable OpenTelemetry in Application Insights
  8. Application Insights connection strings
  9. Migrate from instrumentation keys to connection strings
  10. Azure Monitor OpenTelemetry Exporter client library for Python
  11. Configure automatic data collection and resource detectors for Azure Monitor OpenTelemetry
  12. Azure Monitor OpenTelemetry Distro client library for Python
  13. Enable Application Insights for Python applications on Azure App Service
  14. Microsoft Entra authentication for Application Insights
  15. Troubleshoot OpenTelemetry issues in Python
  16. Filter OpenTelemetry in Application Insights
  17. Sampling in Application Insights with OpenTelemetry
  18. Data collection transformations in Azure Monitor
  19. Create a transformation in Azure Monitor
  20. Application Insights FAQ
  21. Configure OpenTelemetry in Application Insights
  22. Live metrics: monitor and diagnose with 1-second latency
  23. Application Insights telemetry data model
  24. OpenTelemetry trace SDK specification