![]() |
VOOZH | about |
dotnet add package Azure.Monitor.OpenTelemetry.Exporter --version 1.8.1
NuGet\Install-Package Azure.Monitor.OpenTelemetry.Exporter -Version 1.8.1
<PackageReference Include="Azure.Monitor.OpenTelemetry.Exporter" Version="1.8.1" />
<PackageVersion Include="Azure.Monitor.OpenTelemetry.Exporter" Version="1.8.1" />Directory.Packages.props
<PackageReference Include="Azure.Monitor.OpenTelemetry.Exporter" />Project file
paket add Azure.Monitor.OpenTelemetry.Exporter --version 1.8.1
#r "nuget: Azure.Monitor.OpenTelemetry.Exporter, 1.8.1"
#:package Azure.Monitor.OpenTelemetry.Exporter@1.8.1
#addin nuget:?package=Azure.Monitor.OpenTelemetry.Exporter&version=1.8.1Install as a Cake Addin
#tool nuget:?package=Azure.Monitor.OpenTelemetry.Exporter&version=1.8.1Install as a Cake Tool
The OpenTelemetry .NET exporters which send telemetry data to Azure Monitor following the OpenTelemetry Specification.
If you are currently using the Application Insights SDK and want to migrate to OpenTelemetry, please follow our migration guide.
If you are currently using OpenTelemetry and want to send telemetry data to Azure Monitor, please follow our getting started guide.
Install the Azure Monitor Exporter for OpenTelemetry .NET with NuGet:
dotnet add package Azure.Monitor.OpenTelemetry.Exporter
Nightly builds are available from this repo's dev feed. These are provided without support and are not intended for production workloads.
The following examples demonstrate how to add the AzureMonitorExporter to your OpenTelemetry configuration.
It's important to keep the TracerProvider, MeterProvider, and LoggerFactory instances active throughout the process lifetime. These must be properly disposed when your application is shutting down to flush any remaining telemetry items.
Traces
var tracerProvider = Sdk.CreateTracerProviderBuilder()
.AddAzureMonitorTraceExporter(options => options.ConnectionString = "InstrumentationKey=00000000-0000-0000-0000-000000000000")
.Build();
For a complete example see TraceDemo.cs.
Metrics
var meterProvider = Sdk.CreateMeterProviderBuilder()
.AddAzureMonitorMetricExporter(options => options.ConnectionString = "InstrumentationKey=00000000-0000-0000-0000-000000000000")
.Build();
For a complete example see MetricDemo.cs.
Logs
var loggerFactory = LoggerFactory.Create(builder =>
{
builder.AddOpenTelemetry(logging =>
{
logging.AddAzureMonitorLogExporter(options => options.ConnectionString = "InstrumentationKey=00000000-0000-0000-0000-000000000000");
});
});
For a complete example see LogDemo.cs.
Starting with the 1.4.0-beta.3 version you can use the cross-cutting UseAzureMonitorExporter extension to simplify registration of the OTLP exporter for all signals (traces, metrics, and logs).
The cross cutting extension is currently only available when using the AddOpenTelemetry extension in the
OpenTelemetry.Extensions.Hosting package.
The following example demonstrates how to add the AzureMonitorExporter to your OpenTelemetry configuration by using a single API.
To use this API, you need to add OpenTelemetry to a ServiceCollection.
This approach will also enable LiveMetrics.
LiveMetrics can be disabled by setting options.EnableLiveMetrics = false.
appBuilder.Services.AddOpenTelemetry()
.UseAzureMonitorExporter(options => {
options.ConnectionString = "InstrumentationKey=00000000-0000-0000-0000-000000000000";
});
Azure Active Directory (AAD) authentication is an optional feature that can be used with the Azure Monitor Exporter. This is made easy with the Azure Identity library, which provides support for authenticating Azure SDK clients with their corresponding Azure services.
There are two options to enable AAD authentication. Note that if both have been set AzureMonitorExporterOptions will take precedence.
Set your Credential to the AzureMonitorExporterOptions.
var credential = new DefaultAzureCredential();
var tracerProvider = Sdk.CreateTracerProviderBuilder()
.AddAzureMonitorTraceExporter(options =>
{
options.ConnectionString = "InstrumentationKey=00000000-0000-0000-0000-000000000000";
options.Credential = credential;
})
.Build();
Provide your Credential to the AddAzureMonitorExporter method.
var credential = new DefaultAzureCredential();
var tracerProvider = Sdk.CreateTracerProviderBuilder()
.AddAzureMonitorTraceExporter(options => options.ConnectionString = "InstrumentationKey=00000000-0000-0000-0000-000000000000", credential)
.Build();
Some key concepts for .NET include:
Overview of .NET distributed tracing: Distributed tracing is a diagnostic technique that helps engineers localize failures and performance issues within applications, especially those that may be distributed across multiple machines or processes.
Overview of Logging in .NET: .NET supports a logging API that works with a variety of built-in and third-party logging providers.
Some key concepts for Azure Monitor include:
Some key concepts for OpenTelemetry include:
OpenTelemetry: OpenTelemetry is a set of libraries used to collect and export telemetry data (metrics, logs, and traces) for analysis in order to understand your software's performance and behavior.
Instrumentation: The ability to call the OpenTelemetry API directly by any application is facilitated by instrumentation. A library that enables OpenTelemetry observability for another library is called an Instrumentation Library.
Tracing Signal: Trace refers to distributed tracing. It can be thought of as a directed acyclic graph (DAG) of Spans, where the edges between Spans are defined as parent/child relationship.
Sampling:
Sampling is a mechanism to control the noise and overhead introduced by OpenTelemetry by reducing the number of samples of traces collected and sent to the backend.
Default Sampling: By default, the Azure Monitor Exporter uses RateLimitedSampler with a rate of 5.0 traces per second. This provides cost-effective telemetry collection for most applications. To change the sampling behavior:
For rate-limited sampling: Set TracesPerSecond in AzureMonitorExporterOptions:
.AddAzureMonitorTraceExporter(options => {
options.TracesPerSecond = 10.0; // Sample 10 traces per second
})
For percentage-based sampling: Set SamplingRatio and clear TracesPerSecond:
.AddAzureMonitorTraceExporter(options => {
options.SamplingRatio = 0.5f; // Sample 50% of traces
options.TracesPerSecond = null;
})
Via environment variables:
OTEL_TRACES_SAMPLER=microsoft.rate_limited
OTEL_TRACES_SAMPLER_ARG=10
or
OTEL_TRACES_SAMPLER=microsoft.fixed_percentage
OTEL_TRACES_SAMPLER_ARG=0.5
Metric Signal: OpenTelemetry allows to record raw measurements or metrics with predefined aggregation and a set of attributes (dimensions).
Log Signal: A recording of an event. Typically the record includes a timestamp indicating when the event happened as well as other data that describes what happened, where it happened, etc.
For more information on the OpenTelemetry project, please review the OpenTelemetry Specifications.
Refer to Program.cs for a complete demo.
Log scopes allow you to add additional properties to the logs generated by your application. Although the Azure Monitor Exporter does support scopes, this feature is off by default in OpenTelemetry. To leverage log scopes, you must explicitly enable them.
To include the scope with your logs, set OpenTelemetryLoggerOptions.IncludeScopes to true in your application's configuration:
var loggerFactory = LoggerFactory.Create(builder =>
{
builder.AddOpenTelemetry(logging =>
{
logging.AddAzureMonitorLogExporter(options => options.ConnectionString = "InstrumentationKey=00000000-0000-0000-0000-000000000000");
logging.IncludeScopes = true;
});
});
When using ILogger scopes, use a List<KeyValuePair<string, object?>> or IReadOnlyList<KeyValue<string, object?>> as the state for best performance.
All logs written within the context of the scope will include the specified information.
Azure Monitor will add these scope values to the Log's CustomProperties.
List<KeyValuePair<string, object?>> scope =
[
new("scopeKey", "scopeValue")
];
using (logger.BeginScope(scope))
{
logger.LogInformation("Example message.");
}
In scenarios involving multiple scopes or a single scope with multiple key-value pairs, if duplicate keys are present, only the first occurrence of the key-value pair from the outermost scope will be recorded. However, when the same key is utilized both within a logging scope and directly in the log statement, the value specified in the log message template will take precedence.
Azure Monitor relies on OpenTelemetry's Log Signal to create CustomEvents.
For .NET, users will use ILogger and place an attribute named "microsoft.custom_event.name" in the message template.
Severity and CategoryName are not recorded in the CustomEvent.
To send a CustomEvent via ILogger, include the "microsoft.custom_event.name" attribute in the message template.
Note: This example shows LogInformation, but any Log method can be used.
Severity is not recorded, but depending on your configuration it may be filtered out.
Users should take care to select a severity for CustomEvents that is not filtered out by their configuration.
var loggerFactory = LoggerFactory.Create(builder =>
{
builder.AddOpenTelemetry(logging =>
{
logging.AddAzureMonitorLogExporter();
});
});
var logger = loggerFactory.CreateLogger(logCategoryName);
logger.LogInformation("{microsoft.custom_event.name} {key1} {key2}", "MyCustomEventName", "value1", "value2");
This example generates a CustomEvent structured like this:
{
"name": "Event",
"data": {
"baseType": "EventData",
"baseData": {
"name": "MyCustomEventName",
"properties": {
"key1": "value1",
"key2": "value2"
}
}
}
}
The Azure Monitor exporter uses EventSource for its own internal logging. The exporter logs are available to any EventListener by opting into the source named "OpenTelemetry-AzureMonitor-Exporter".
OpenTelemetry also provides it's own self-diagnostics feature to collect internal logs. An example of this is available in our demo project here.
For more information on Azure SDK, please refer to this website
See CONTRIBUTING.md for details on contribution process.
This library supports usage in .NET applications compiled with AOT (Ahead-of-Time) compilation. All core features of the Azure Monitor Exporter are compatible with AOT, including telemetry export for traces, metrics, and logs.
Important:
While AOT is supported, automatic configuration binding from appsettings.json or other IConfiguration sources is not supported in AOT-compiled applications.
This is due to .NET limitations on reflection-based binding APIs (such as ConfigurationBinder.Bind and Get<T>()) in AOT scenarios.
Workaround:
In AOT scenarios, you can configure the Azure Monitor Exporter using one of the following approaches:
Environment Variable: Set the APPLICATIONINSIGHTS_CONNECTION_STRING environment variable to configure the connection string.
Programmatic Configuration: Set the AzureMonitorExporterOptions directly in your application code:
builder.Services.AddOpenTelemetry()
.UseAzureMonitorExporter(options =>
{
options.ConnectionString = "<your-connection-string>";
// Set other options as needed
});
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 net5.0 was computed. net5.0-windows net5.0-windows was computed. net6.0 net6.0 was computed. net6.0-android net6.0-android was computed. net6.0-ios net6.0-ios was computed. net6.0-maccatalyst net6.0-maccatalyst was computed. net6.0-macos net6.0-macos was computed. net6.0-tvos net6.0-tvos was computed. net6.0-windows net6.0-windows was computed. net7.0 net7.0 was computed. net7.0-android net7.0-android was computed. net7.0-ios net7.0-ios was computed. net7.0-maccatalyst net7.0-maccatalyst was computed. net7.0-macos net7.0-macos was computed. net7.0-tvos net7.0-tvos was computed. net7.0-windows net7.0-windows was computed. net8.0 net8.0 is compatible. net8.0-android net8.0-android was computed. net8.0-browser net8.0-browser was computed. net8.0-ios net8.0-ios was computed. net8.0-maccatalyst net8.0-maccatalyst was computed. net8.0-macos net8.0-macos was computed. net8.0-tvos net8.0-tvos was computed. net8.0-windows net8.0-windows was computed. net9.0 net9.0 was computed. net9.0-android net9.0-android was computed. net9.0-browser net9.0-browser was computed. net9.0-ios net9.0-ios was computed. net9.0-maccatalyst net9.0-maccatalyst was computed. net9.0-macos net9.0-macos was computed. net9.0-tvos net9.0-tvos was computed. net9.0-windows net9.0-windows was computed. net10.0 net10.0 is compatible. net10.0-android net10.0-android was computed. net10.0-browser net10.0-browser was computed. net10.0-ios net10.0-ios was computed. net10.0-maccatalyst net10.0-maccatalyst was computed. net10.0-macos net10.0-macos was computed. net10.0-tvos net10.0-tvos was computed. net10.0-windows net10.0-windows was computed. |
| .NET Core | netcoreapp2.0 netcoreapp2.0 was computed. netcoreapp2.1 netcoreapp2.1 was computed. netcoreapp2.2 netcoreapp2.2 was computed. netcoreapp3.0 netcoreapp3.0 was computed. netcoreapp3.1 netcoreapp3.1 was computed. |
| .NET Standard | netstandard2.0 netstandard2.0 is compatible. netstandard2.1 netstandard2.1 was computed. |
| .NET Framework | net461 net461 was computed. net462 net462 was computed. net463 net463 was computed. net47 net47 was computed. net471 net471 was computed. net472 net472 was computed. net48 net48 was computed. net481 net481 was computed. |
| MonoAndroid | monoandroid monoandroid was computed. |
| MonoMac | monomac monomac was computed. |
| MonoTouch | monotouch monotouch was computed. |
| Tizen | tizen40 tizen40 was computed. tizen60 tizen60 was computed. |
| Xamarin.iOS | xamarinios xamarinios was computed. |
| Xamarin.Mac | xamarinmac xamarinmac was computed. |
| Xamarin.TVOS | xamarintvos xamarintvos was computed. |
| Xamarin.WatchOS | xamarinwatchos xamarinwatchos was computed. |
Showing the top 5 NuGet packages that depend on Azure.Monitor.OpenTelemetry.Exporter:
| Package | Downloads |
|---|---|
|
Microsoft.ApplicationInsights
Application Insights Base API. This package provides core functionality for transmission of all Application Insights Telemetry Types and is a dependent package for all other Application Insights packages. Please install the platform specific package for the best experience. Privacy statement: https://go.microsoft.com/fwlink/?LinkId=512156 |
|
|
Azure.Monitor.OpenTelemetry.AspNetCore
An OpenTelemetry .NET distro that exports to Azure Monitor |
|
|
Apollo13.DataAccessLayer
Data access layer for SQL server |
|
|
Elvia.Telemetry
Common logging/telemetry functionality to used by all services within the Elvia ecosystem. |
|
|
Altinn.App.Api
This class library holds all the API controllers used by a standard Altinn 3 App. |
Showing the top 20 popular GitHub repositories that depend on Azure.Monitor.OpenTelemetry.Exporter:
| Repository | Stars |
|---|---|
|
microsoft/semantic-kernel
Integrate cutting-edge LLM technology quickly and easily into your apps
|
|
|
microsoft/aspire
Aspire is the tool for code-first, extensible, observable dev and deploy.
|
|
|
microsoft/kiota
OpenAPI based HTTP Client code generator
|
|
|
dotnet/sdk
Core functionality needed to create .NET Core projects, that is shared between Visual Studio and CLI
|
|
|
microsoft/dotnet-podcasts
.NET reference application shown at .NET Conf featuring ASP.NET Core, Blazor, .NET MAUI, Microservices, Orleans, Playwright, and more!
|
|
|
Squidex/squidex
Headless CMS and Content Managment Hub
|
|
|
phongnguyend/Practical.CleanArchitecture
Full-stack .Net 10 Clean Architecture (Microservices, Modular Monolith, Monolith), Blazor, Angular 21, React 19, Vue 3.5, BFF with YARP, NextJs 16, Domain-Driven Design, CQRS, SOLID, Asp.Net Core Identity Custom Storage, OpenID Connect, EF Core, OpenTelemetry, SignalR, Background Services, Health Checks, Rate Limiting, Clouds (Azure, AWS, GCP), ...
|
|
|
Azure/azure-functions-host
The host/runtime that powers Azure Functions
|
|
|
Azure/durabletask
Durable Task Framework allows users to write long running persistent workflows in C# using the async/await capabilities.
|
|
|
bitfoundation/bitplatform
Build all of your apps using what you already know and love ❤️
|
|
|
dotnet/dotnet
Home of .NET's Virtual Monolithic Repository which includes all the code needed to build the .NET SDK.
|
|
|
polymind-inc/acmebot
Automated ACME SSL/TLS certificate management built around Azure Key Vault
|
|
|
notifo-io/notifo
Multi channel notification service for collaboration tools, e-commerce, news service and more.
|
|
|
doghappy/socket.io-client-csharp
socket.io-client implemention for .NET
|
|
|
Azure/azure-cosmos-dotnet-v3
.NET SDK for Azure Cosmos DB for the core SQL API
|
|
|
microsoft/ApplicationInsights-dotnet
ApplicationInsights-dotnet
|
|
|
nkdAgility/azure-devops-migration-tools
Azure DevOps Migration Tools allow you to migrate Teams, Backlogs, Work Items, Tasks, Test Cases, and Plans & Suits from one Project to another in Azure DevOps / TFS both within the same Organisation, and between Organisations.
|
|
|
Azure/azure-functions-templates
Azure functions templates for the azure portal, CLI, and VS
|
|
|
axzxs2001/Asp.NetCoreExperiment
原来所有项目都移动到**OleVersion**目录下进行保留。新的案例装以.net 5.0为主,一部分对以前案例进行升级,一部分将以前的工作经验总结出来,以供大家参考!
|
|
|
rwjdk/MicrosoftAgentFrameworkSamples
Samples demonstrating the Microsoft Agent Framework in C#
|
| Version | Downloads | Last Updated | |
|---|---|---|---|
| 1.8.1 | 323,663 | 5/21/2026 | |
| 1.8.0 | 2,790,258 | 4/30/2026 | |
| 1.7.0 | 2,487,360 | 3/30/2026 | |
| 1.6.0 | 3,779,814 | 1/29/2026 | |
| 1.6.0-beta.2 | 17,711 | 1/13/2026 | |
| 1.6.0-beta.1 | 28,152 | 12/3/2025 | |
| 1.5.0 | 8,818,063 | 11/14/2025 | |
| 1.5.0-beta.1 | 29,900 | 10/16/2025 | |
| 1.4.0 | 12,487,494 | 5/9/2025 | |
| 1.4.0-beta.3 | 189,347 | 4/2/2025 | |
| 1.4.0-beta.2 | 972,090 | 10/11/2024 | |
| 1.4.0-beta.1 | 291,456 | 7/16/2024 | |
| 1.3.0 | 19,063,328 | 6/10/2024 | |
| 1.3.0-beta.2 | 104,456 | 5/16/2024 | |
| 1.3.0-beta.1 | 307,298 | 2/8/2024 | |
| 1.2.0 | 3,692,487 | 1/24/2024 | |
| 1.1.0 | 1,200,420 | 11/29/2023 | |
| 1.0.0 | 1,689,560 | 9/20/2023 | |
| 1.0.0-beta.14 | 244,317 | 8/9/2023 | 1.0.0-beta.14 is deprecated because it is no longer maintained. |
| 1.0.0-beta.13 | 288,808 | 7/14/2023 | 1.0.0-beta.13 is deprecated because it is no longer maintained. |