AI-200
Azure
Back to Observe and troubleshoot apps on Azure

Instrument an app with OpenTelemetry

Explore OpenTelemetry and its role in observability

Overview

Observability means you can explain what your AI app is doing, where time is spent, and why a request failed — across services, queues, and databases. For AI-200, that starts with OpenTelemetry instrumentation and ends in Azure Monitor Application Insights, queried with KQL.

Diagram
Your App (OpenTelemetry SDK)
      │  spans / traces / metrics / logs
Azure Monitor Exporter
Application Insights (ingestion)
      │  stored as tables
Log Analytics Workspace  →  queried with KQL

Exam tips

  • OpenTelemetry is vendor-neutral — same code can export to Azure Monitor, Datadog, Jaeger, etc.
  • Application Insights is the APM layer of Azure Monitor; data lives in a Log Analytics workspace
  • Map OTel terms to Azure: Trace → operation_Id, Span → request/dependency row, attributes → custom dimensions
  • Know the three signals: traces, metrics, and logs
  • Distributed tracing only works when trace context (traceparent) propagates across every hop

When to use vs when not to use

Use OpenTelemetry + App InsightsPrefer something else
Multi-service AI pipelines (API → queue → worker → DB)Single-machine scripts with no ops needs
Debugging latency across Functions, ACA, Cosmos DBOne-off local profiling only
Exam scenarios asking for correlation / end-to-end tracesPure infrastructure metrics (VM CPU) without app context

OpenTelemetry

OpenTelemetry (OTel) is a vendor-neutral standard (API + SDK) for generating telemetry — traces, metrics, and logs. It is not Azure-specific. You instrument once and choose an exporter for the backend you want.

OpenTelemetry gives you:

  • A consistent API across languages (Python, .NET, Java, Node, Go)
  • Auto-instrumentation for common libraries (HTTP clients, frameworks, DB drivers)
  • Manual spans for AI-specific work (embedding generation, RAG retrieval, model calls)

Use case: An inference API calls Cosmos DB for vector search, then Azure OpenAI. OTel spans show which hop is slow.


Azure Monitor and Application Insights

Azure Monitor is Azure’s umbrella observability platform (metrics, logs, alerts, workbooks). Application Insights is the application performance monitoring (APM) part — where your traces and spans land for apps.

Under the hood, Application Insights data is stored in a Log Analytics workspace. You explore it in the portal UI (Failures, Performance, Transaction search) or by writing KQL in the Logs blade.

ConceptDefinition
Azure MonitorPlatform-wide observability: metrics, logs, alerts, dashboards
Application InsightsApp-focused APM (requests, dependencies, exceptions, traces)
Log Analytics workspaceShared log store that App Insights and many Azure resources write into
KQLKusto Query Language — query language for Log Analytics / App Insights

Vocabulary mapping (OTel → Azure)

OpenTelemetryAzure Monitor / App Insights
TraceOperation (grouped by operation_Id / OperationId)
SpanRow in AppRequests, AppDependencies, AppTraces, etc.
Span attributesCustom dimensions (customDimensions)
Trace context propagationDistributed tracing / correlation
SamplerSampling (adaptive or ratio-based) to control cost

The three pillars

Traces record the path of a single request through services. Metrics are numeric aggregations over time (latency, error rate, token count). Logs are free-form messages for detail.

For AI solutions, combine all three:

  • Traces → find which dependency failed in a RAG pipeline
  • Metrics → alert when P95 embedding latency rises
  • Logs → capture model name, document ID, or prompt hash as context

Learn more