JGUZDV.AspNetCore.Extensions.OpenTelemetry 1.1.7

dotnet add package JGUZDV.AspNetCore.Extensions.OpenTelemetry --version 1.1.7
                    
NuGet\Install-Package JGUZDV.AspNetCore.Extensions.OpenTelemetry -Version 1.1.7
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="JGUZDV.AspNetCore.Extensions.OpenTelemetry" Version="1.1.7" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="JGUZDV.AspNetCore.Extensions.OpenTelemetry" Version="1.1.7" />
                    
Directory.Packages.props
<PackageReference Include="JGUZDV.AspNetCore.Extensions.OpenTelemetry" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add JGUZDV.AspNetCore.Extensions.OpenTelemetry --version 1.1.7
                    
#r "nuget: JGUZDV.AspNetCore.Extensions.OpenTelemetry, 1.1.7"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package JGUZDV.AspNetCore.Extensions.OpenTelemetry@1.1.7
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=JGUZDV.AspNetCore.Extensions.OpenTelemetry&version=1.1.7
                    
Install as a Cake Addin
#tool nuget:?package=JGUZDV.AspNetCore.Extensions.OpenTelemetry&version=1.1.7
                    
Install as a Cake Tool

JGUZDV.Extensions.AspNetCore.OpenTelemetry

General

Provides a simple preconfigured way for ASP.NET Core web applications to integrate OpenTelemetry transferring data to Azure Monitor resources.

How to use

To add general OpenTelemetry support for your ASP.NET Core web app, just add the following line (builder is a WebApplicationBuilder):

builder.AddJGUZDVOpenTelemetry();

How to configure

Basic configuration settings to initialize the services should be configured as in the following example in your appsettings (root level):

  ...
  "OpenTelemetry": {
    "AzureMonitor": {
      "ConnectionString": "<AzureMonitorConnectionString>"
    },
    "ServiceNamespace": "<WebAppNamespace>",
    "ServiceName": "<WebAppName>",
    "UseMeter": {
      "MeterName": "<WebAppMeterName>",
      "MeterVersion": "<WebAppMeterVersion>"
    }
  },
  ...

Explanation: If no "OpenTelemetry" section can be found, nothing will happen at all. If such a section is present, the included parameters will be checked. ConnectionString is obviously a mandatory config parameter. WebAppNamespace should describe a summarizing border or boundary, and WebAppName should be the concrete and unique name of the WebApp. The name and namespace parameters should be about 10 to 15 characters, the strings should not include any whitespace or special characters. The section "UseMeter" is optional, but if it is present, the two inner fields are mandatory.

Meter

Configure "UseMeter" to send metrics. To implement metrics, create a service inheriting from AbstractJguZdvMeter, and add it to the service container as a singleton (OpenTelemetry API's are thread-safe, according to the docs). This is what you should add to your Program.cs (complete example):

// Default OpenTelemetry config, needs the OpenTelemetry config section.
builder.AddJGUZDVOpenTelemetry();
builder.Services.AddSingleton<MeterContainer>();

Full example for a MeterContainer:

public class MeterContainer : AbstractJguZdvMeter
{
    private readonly Counter<int> _exampleCounter;


    public MeterContainer(IOptions<AspNetCoreOpenTelemetryOptions> options) : base(options)
    {
        _exampleCounter = Meter.CreateCounter<int>(
            name: "webappname.example.count",
            description: "An example counter for your webapp.");
    }

    // Call this to send count metrics.
    public void CountExample()
    {
        _exampleCounter.Add(1)
    }
}

Note:

  • Please find meaningful names for your instruments!
  • The needed options are prepared in the AddJGUZDVOpenTelemetry extension method.
  • The "Meter" instance is created in the base constructor.
Product Compatible and additional computed target framework versions.
.NET net9.0 is compatible.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on JGUZDV.AspNetCore.Extensions.OpenTelemetry:

Package Downloads
JGUZDV.AspNetCore.Hosting

HostBuilders for our default setup.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.1.7 82 9/29/2026
1.1.6 236 5/22/2026
1.1.5 352 9/3/2025
1.1.4 236 9/3/2025
1.1.3 247 6/24/2025
1.1.2 222 1/3/2025
1.1.1 202 11/25/2024
1.1.0 180 11/14/2024
1.0.1 187 11/14/2024
1.0.0 297 3/18/2024