Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
This guidance shows you how to add observability to your application with Microsoft OpenTelemetry Distro. The Distro automatically collects traces, metrics, and logs with built-in instrumentations, and exports the telemetry to Azure Monitor, any OpenTelemetry Protocol (OTLP) endpoint, or Microsoft Agent 365.
Install the package
The Microsoft OpenTelemetry Distro package identifiers and install commands are:
| Language | Package | Install command |
|---|---|---|
| Python | microsoft-opentelemetry |
pip install microsoft-opentelemetry |
| Node.js | @microsoft/opentelemetry |
npm install @microsoft/opentelemetry |
| .NET | Microsoft.OpenTelemetry |
dotnet add package Microsoft.OpenTelemetry |
Initialize the Distro
Distro initialization follows the same conceptual flow across supported languages:
- Initialize the Distro early enough for automatic instrumentations to observe the libraries and frameworks used by the application.
- Select the destination categories that apply to the scenario, such as Azure Monitor, Microsoft Agent 365, OTLP, or local development output.
- Use Distro defaults for resource detection, signal pipelines, exporters, processors, and built-in instrumentations.
- Add application-specific OpenTelemetry sources or meters when the application emits custom telemetry outside the Distro defaults.
- Ensure the application flushes telemetry during shutdown when the language runtime or hosting model requires it.
from microsoft.opentelemetry import use_microsoft_opentelemetry
use_microsoft_opentelemetry()
Configure destinations
Use Distro configuration to choose the destination categories for the application. The exact destination setup depends on the product surface, but the common Distro configuration pattern is to initialize the Distro and provide destination options.
Azure Monitor
from microsoft.opentelemetry import use_microsoft_opentelemetry
use_microsoft_opentelemetry(
azure_monitor_connection_string="InstrumentationKey=...;IngestionEndpoint=...",
)
OpenTelemetry Protocol (OTLP)
export OTEL_EXPORTER_OTLP_ENDPOINT=http://localhost:4317
from microsoft.opentelemetry import use_microsoft_opentelemetry
use_microsoft_opentelemetry()
Microsoft Agent 365
from microsoft.opentelemetry import use_microsoft_opentelemetry
def token_resolver(agent_id, tenant_id):
return "your-token"
use_microsoft_opentelemetry(
enable_a365=True,
a365_token_resolver=token_resolver,
a365_cluster_category="prod",
)