![]() |
VOOZH | about |
dotnet add package OpenTelemetry.Extensions.Hosting --version 1.16.0
NuGet\Install-Package OpenTelemetry.Extensions.Hosting -Version 1.16.0
<PackageReference Include="OpenTelemetry.Extensions.Hosting" Version="1.16.0" />
<PackageVersion Include="OpenTelemetry.Extensions.Hosting" Version="1.16.0" />Directory.Packages.props
<PackageReference Include="OpenTelemetry.Extensions.Hosting" />Project file
paket add OpenTelemetry.Extensions.Hosting --version 1.16.0
#r "nuget: OpenTelemetry.Extensions.Hosting, 1.16.0"
#:package OpenTelemetry.Extensions.Hosting@1.16.0
#addin nuget:?package=OpenTelemetry.Extensions.Hosting&version=1.16.0Install as a Cake Addin
#tool nuget:?package=OpenTelemetry.Extensions.Hosting&version=1.16.0Install as a Cake Tool
dotnet add package OpenTelemetry.Extensions.Hosting
The OpenTelemetry.Extensions.Hosting package provides extension methods for
automatically starting (and stopping) OpenTelemetry tracing (TracerProvider)
and metrics (MeterProvider) in ASP.NET
Core and
.NET Generic
hosts. These are completely optional extensions meant to simplify the
management of the OpenTelemetry SDK lifecycle.
Targeting Microsoft.Extensions.DependencyInjection.IServiceCollection:
AddOpenTelemetry: Registers an
IHostedService
to automatically start tracing and/or metric services in the supplied
IServiceCollection
and then returns an OpenTelemetryBuilder class.
AddOpenTelemetry should be called by application host code only. Library
authors see: Registration extension method guidance for library
authors.
Multiple calls to AddOpenTelemetry will NOT result in multiple
providers. Only a single TracerProvider and/or MeterProvider will be
created in the target IServiceCollection. To establish multiple providers
use the Sdk.CreateTracerProviderBuilder() and/or
Sdk.CreateMeterProviderBuilder() methods. See TracerProvider
configuration
and Building a
MeterProvider
for more details.
OpenTelemetryBuilder methods:
ConfigureResource: Registers a callback action to configure the
ResourceBuilder for tracing and metric providers.
WithTracing: Enables tracing and optionally configures the
TracerProvider.
WithMetrics: Enables metrics and optionally configures the
MeterProvider.
The following example shows how to register OpenTelemetry tracing & metrics in an ASP.NET Core host using the OpenTelemetry.Extensions.Hosting extensions.
using Microsoft.AspNetCore.Builder;
using Microsoft.Extensions.DependencyInjection;
using OpenTelemetry.Metrics;
using OpenTelemetry.Trace;
var appBuilder = WebApplication.CreateBuilder(args);
appBuilder.Services.AddOpenTelemetry()
.ConfigureResource(builder => builder.AddService(serviceName: "MyService"))
.WithTracing(builder => builder.AddConsoleExporter())
.WithMetrics(builder => builder.AddConsoleExporter());
var app = appBuilder.Build();
app.Run();
A fully functional example can be found here.
To dynamically add resources at startup from the dependency injection you can
provide an IResourceDetector.
To make use of it add it to the dependency injection and then you can use the
IServiceProvider to add it to OpenTelemetry:
public class MyResourceDetector : IResourceDetector
{
private readonly IWebHostEnvironment webHostEnvironment;
public MyResourceDetector(IWebHostEnvironment webHostEnvironment)
{
this.webHostEnvironment = webHostEnvironment;
}
public Resource Detect()
{
return ResourceBuilder.CreateEmpty()
.AddService(serviceName: this.webHostEnvironment.ApplicationName)
.AddAttributes(new Dictionary<string, object> { ["host.environment"] = this.webHostEnvironment.EnvironmentName })
.Build();
}
}
services.AddSingleton<MyResourceDetector>();
services.AddOpenTelemetry()
.ConfigureResource(builder =>
builder.AddDetector(sp => sp.GetRequiredService<MyResourceDetector>()))
.WithTracing(builder => builder.AddConsoleExporter())
.WithMetrics(builder => builder.AddConsoleExporter());
Pre-release versions (all versions prior to 1.4.0) of
OpenTelemetry.Extensions.Hosting contained signal-specific methods for
configuring tracing and metrics:
AddOpenTelemetryTracing: Configure OpenTelemetry and register an
IHostedService
to automatically start tracing services in the supplied
IServiceCollection.
AddOpenTelemetryMetrics: Configure OpenTelemetry and register an
IHostedService
to automatically start metric services in the supplied
IServiceCollection.
These methods were marked obsolete and later removed. You should migrate your
code to the new AddOpenTelemetry method documented above. Refer the
old
and
new
versions of the example application to assist you in your migration.
TBD
| 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 is compatible. 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 is compatible. 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 OpenTelemetry.Extensions.Hosting:
| Package | Downloads |
|---|---|
|
Microsoft.ApplicationInsights.AspNetCore
Application Insights for ASP.NET Core web applications. See https://azure.microsoft.com/documentation/articles/app-insights-asp-net-five/ for more information. Privacy statement: https://go.microsoft.com/fwlink/?LinkId=512156 |
|
|
Microsoft.ApplicationInsights.WorkerService
Application Insights for .NET Core Worker Service (messaging, background tasks, and any non-HTTP workloads) applications. See https://docs.microsoft.com/azure/azure-monitor/app/worker-service for more information. Privacy statement: https://go.microsoft.com/fwlink/?LinkId=512156 |
|
|
Azure.Monitor.OpenTelemetry.Exporter
An OpenTelemetry .NET exporter that exports to Azure Monitor |
|
|
Azure.Monitor.OpenTelemetry.AspNetCore
An OpenTelemetry .NET distro that exports to Azure Monitor |
|
|
Aspire.Hosting
Core abstractions for the Aspire application model. |
Showing the top 20 popular GitHub repositories that depend on OpenTelemetry.Extensions.Hosting:
| Repository | Stars |
|---|---|
|
microsoft/semantic-kernel
Integrate cutting-edge LLM technology quickly and easily into your apps
|
|
|
dotnet/maui
.NET MAUI is the .NET Multi-platform App UI, a framework for building native device applications spanning mobile, tablet, and desktop.
|
|
|
jasontaylordev/CleanArchitecture
Clean Architecture Solution Template for ASP.NET Core
|
|
|
ardalis/CleanArchitecture
Clean Architecture Solution Template: A proven Clean Architecture Template for ASP.NET Core 10
|
|
|
dotnet/runtime
.NET is a cross-platform runtime for cloud, mobile, desktop, and IoT apps.
|
|
|
JustArchiNET/ArchiSteamFarm
C# application with primary purpose of farming Steam cards from multiple accounts simultaneously.
|
|
|
dotnet/AspNetCore.Docs
Documentation for ASP.NET Core
|
|
|
dotnet/orleans
Cloud Native application framework for .NET
|
|
|
dotnet/eShop
A reference .NET application implementing an eCommerce site
|
|
|
dodyg/practical-aspnetcore
Practical samples of ASP.NET Core 11, 10, 9, 8.0, 7.0, 6.0, 5.0, 3.1, 2.2, and 2.1,projects you can use. Readme contains explanations on all projects.
|
|
|
dotnet/yarp
A toolkit for developing high-performance HTTP reverse proxy applications.
|
|
|
MassTransit/MassTransit
Distributed Application Framework for .NET
|
|
|
quartznet/quartznet
Quartz Enterprise Scheduler .NET
|
|
|
fullstackhero/dotnet-starter-kit
Production Grade Cloud-Ready .NET 10 Starter Kit (Web API + React Client) with Multitenancy Support, and Clean/Modular Architecture that saves roughly 200+ Development Hours! All Batteries Included.
|
|
|
microsoft/aspire
Aspire is the tool for code-first, extensible, observable dev and deploy.
|
|
|
Sylinko/Everywhere
On-screen aware AI assistant for your desktop. Uses current app context, multiple LLMs, and MCP tools to help you act across apps.
|
|
|
Azure/azure-sdk-for-net
This repository is for active development of the Azure SDK for .NET. For consumers of the SDK we recommend visiting our public developer docs at https://learn.microsoft.com/dotnet/azure/ or our versioned developer docs at https://azure.github.io/azure-sdk-for-net.
|
|
|
graphql-dotnet/graphql-dotnet
GraphQL for .NET
|
|
|
kurrent-io/KurrentDB
KurrentDB is a database that's engineered for modern software applications and event-driven architectures. Its event-native design simplifies data modeling and preserves data integrity while the integrated streaming engine solves distributed messaging challenges and ensures data consistency.
|
|
|
ChilliCream/graphql-platform
Welcome to the home of the Hot Chocolate GraphQL server for .NET, the Strawberry Shake GraphQL client for .NET and Nitro the awesome Monaco based GraphQL IDE.
|
| Version | Downloads | Last Updated | |
|---|---|---|---|
| 1.16.0 | 404,438 | 6/10/2026 | |
| 1.16.0-rc.1 | 163 | 6/10/2026 | |
| 1.15.3 | 17,811,249 | 4/21/2026 | |
| 1.15.2 | 1,676,236 | 4/8/2026 | |
| 1.15.1 | 3,964,687 | 3/27/2026 | |
| 1.15.0 | 15,207,899 | 1/21/2026 | |
| 1.14.0 | 24,603,819 | 11/12/2025 | |
| 1.14.0-rc.1 | 68,321 | 10/21/2025 | |
| 1.13.1 | 8,052,106 | 10/9/2025 | |
| 1.13.0 | 2,043,782 | 10/1/2025 | 1.13.0 is deprecated because it has critical bugs. |
| 1.12.0 | 39,866,522 | 4/30/2025 | |
| 1.11.2 | 15,395,193 | 3/4/2025 | |
| 1.11.1 | 6,756,903 | 1/23/2025 | |
| 1.11.0 | 1,577,862 | 1/16/2025 | |
| 1.11.0-rc.1 | 56,773 | 12/12/2024 | |
| 1.10.0 | 10,115,578 | 11/12/2024 | |
| 1.10.0-rc.1 | 19,733 | 11/1/2024 | |
| 1.10.0-beta.1 | 47,538 | 9/30/2024 | |
| 1.9.0 | 73,824,155 | 6/14/2024 | |
| 1.9.0-rc.1 | 526,737 | 6/7/2024 |
For highlights and announcements see: https://github.com/open-telemetry/opentelemetry-dotnet/blob/core-1.16.0/RELEASENOTES.md.
For detailed changes see: https://github.com/open-telemetry/opentelemetry-dotnet/blob/core-1.16.0/src/OpenTelemetry.Extensions.Hosting/CHANGELOG.md.