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.
Note
For .NET, Node.js, and Python applications:
- New app or adopting OpenTelemetry for the first time: Use the Microsoft OpenTelemetry Distro.
- Already using the Azure Monitor OpenTelemetry Distro: No action needed.
- Using Application Insights .NET SDK 2.x: Upgrade to 3.x to minimize reinstrumentation, or start fresh with the Microsoft OpenTelemetry Distro.
For Java applications, use the Azure Monitor OpenTelemetry Distro.
For AI-assisted instrumentation guidance, see the Application Insights instrumentation skill. For guided setup and analysis of existing Application Insights instrumentation, see the Azure MCP Server tools for Azure Monitor.
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.
For other collection and export options, see OpenTelemetry with Azure Monitor.
OpenTelemetry release status
For package details and release notes, see Next steps.
Note
For Azure Function Apps, see Use OpenTelemetry with Azure Functions.
Enable OpenTelemetry with Application Insights
Follow the steps in this section to instrument your application with OpenTelemetry. Select a tab for language-specific instructions.
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 |
For Java, use the agent or native-image integration described in the Java and Java native tabs.
Use the ASP.NET Core tab for web applications and the .NET tab for console and other non-hosted applications.
Prerequisites
- Azure subscription: Create an Azure subscription for free
- Application Insights resource: Create an Application Insights resource
- ASP.NET Core Application using an officially supported version of .NET
Tip
If you're upgrading from Application Insights .NET SDK 2.x, follow the SDK 3.x migration guidance. That upgrade doesn't require switching to the Microsoft OpenTelemetry Distro.
Install the client library
Note
These installation steps are for applications that use the Microsoft OpenTelemetry Distro. They aren't an upgrade requirement for existing Azure Monitor OpenTelemetry Distro users. Don't initialize both distros in the same application. Standalone Azure Monitor exporter packages keep their existing names.
Install the Microsoft.OpenTelemetry NuGet package:
dotnet add package Microsoft.OpenTelemetry
Modify your application
Initialize the Microsoft OpenTelemetry Distro before your application starts handling work. The following examples select Azure Monitor as the destination and read the connection string from the APPLICATIONINSIGHTS_CONNECTION_STRING environment variable. Set that variable before starting your application, as described later in this article.
You can also set the connection string in code. For .NET, use options.AzureMonitor.ConnectionString inside UseMicrosoftOpenTelemetry(). For all supported languages, see Connection string configuration.
In Program.cs, configure the application builder to use the Microsoft OpenTelemetry Distro:
// Import the distro API.
using Microsoft.OpenTelemetry;
// Create the application builder.
var builder = WebApplication.CreateBuilder(args);
// Initialize the Microsoft OpenTelemetry Distro with Azure Monitor export.
builder.UseMicrosoftOpenTelemetry(options =>
{
options.Exporters = ExportTarget.AzureMonitor;
});
// Build and run the application.
var app = builder.Build();
app.Run();
Copy the connection string from your Application Insights resource
The connection string identifies the Application Insights resource that receives your telemetry.
Tip
If you don't already have an Application Insights resource, create one following this guide. We recommend you create a new resource rather than using an existing one.
To copy the connection string:
- Go to the Overview pane of your Application Insights resource.
- Find your connection string.
- Hover over the connection string and select the Copy to clipboard icon.
Paste the connection string in your environment
To paste your connection string, use one of the following methods:
| Method | Supported languages | Recommended for |
|---|---|---|
| Environment variable | All | Production |
Configuration file (applicationinsights.json) |
Java only | Production (Java) |
| Code | .NET, Node.js, Python | Local dev/test only |
Important
We recommend setting the connection string through code only in local development and test environments.
For production, use an environment variable or configuration file (Java only).
Set the Application Insights connection string as an environment variable (recommended for production)
In Bash:
export APPLICATIONINSIGHTS_CONNECTION_STRING="<ConnectionString>"In PowerShell:
$env:APPLICATIONINSIGHTS_CONNECTION_STRING = "<ConnectionString>"Set the Application Insights connection string in a configuration file - Java only
Create a configuration file named
applicationinsights.json, and place it in the same directory asapplicationinsights-agent-3.7.9.jarwith the following content:{ "connectionString": "<ConnectionString>" }Set the Application Insights connection string in code - .NET, Node.js, and Python only
For Microsoft OpenTelemetry Distro options, see the .NET, Node.js, or Python documentation.
Confirm data is flowing
After you configure the distro and set the connection string, run your application and generate traffic or log messages. Open your Application Insights resource in the Azure portal to verify that telemetry appears. It might take a few minutes for data to show up.
Application Insights is now enabled for your application. The following steps are optional and allow for further customization.
Note
As part of using Application Insights instrumentation, we collect and send diagnostic data to Microsoft. This data helps us run and improve Application Insights. Learn more in the Application Insights FAQ.
Important
If you have two or more services that emit telemetry to the same Application Insights resource, you're required to set Cloud Role Names to represent them properly on the Application Map.
Troubleshooting, feedback, and support
Tip
The following sections are available across all OpenTelemetry Distro articles.
Troubleshooting
For troubleshooting information, see Troubleshoot OpenTelemetry issues in .NET and Troubleshoot missing application telemetry in Azure Monitor Application Insights.
OpenTelemetry Feedback
To provide feedback:
- Fill out the OpenTelemetry community's customer feedback survey.
- Tell Microsoft about yourself by joining the OpenTelemetry Early Adopter Community.
- Engage with other Azure Monitor users in the Microsoft Tech Community.
- Make a feature request at the Azure Feedback Forum.
Support
Select a tab for the language of your choice to discover support options.
- For Azure support issues, open an Azure support ticket.
- For OpenTelemetry issues, contact the OpenTelemetry .NET community directly.
- For a list of open issues related to Azure Monitor Exporter, see the GitHub Issues Page.
Next steps
- To review the source code, see the Microsoft OpenTelemetry Distro repository for .NET.
- To review a sample application, see Microsoft OpenTelemetry Distro for ASP.NET Core.
- To install the NuGet package, check for updates, or view release notes, see the Microsoft.OpenTelemetry package.
- For applications that still use
Azure.Monitor.OpenTelemetry.AspNetCore, see the Azure Monitor distro documentation. - To learn more about OpenTelemetry and its community, see the OpenTelemetry .NET GitHub repository.
- To enable usage experiences, enable web or browser user monitoring.