JGUZDV.Extensions.OpenTelemetry
1.0.0
See the version list below for details.
dotnet add package JGUZDV.Extensions.OpenTelemetry --version 1.0.0
NuGet\Install-Package JGUZDV.Extensions.OpenTelemetry -Version 1.0.0
<PackageReference Include="JGUZDV.Extensions.OpenTelemetry" Version="1.0.0" />
<PackageVersion Include="JGUZDV.Extensions.OpenTelemetry" Version="1.0.0" />
<PackageReference Include="JGUZDV.Extensions.OpenTelemetry" />
paket add JGUZDV.Extensions.OpenTelemetry --version 1.0.0
#r "nuget: JGUZDV.Extensions.OpenTelemetry, 1.0.0"
#:package JGUZDV.Extensions.OpenTelemetry@1.0.0
#addin nuget:?package=JGUZDV.Extensions.OpenTelemetry&version=1.0.0
#tool nuget:?package=JGUZDV.Extensions.OpenTelemetry&version=1.0.0
JGUZDV.Extensions.OpenTelemetry
General
Provides a simple preconfigured way for .NET applications to integrate OpenTelemetry transferring data to Azure Monitor resources.
Usage
To add OpenTelemetry support to your .NET application, just add the following line while configuring your HostApplicationBuilder:
builder.AddJGUZDVOpenTelemetry();
or
Host.CreateApplicationBuilder()
.AddJGUZDVOpenTelemetry();
Configuration
These required configuration settings should be configured in your appsettings.json using the follwing example:
...
"OpenTelemetry": {
"AzureMonitor": {
"ConnectionString": "<AzureMonitorConnectionString>"
},
"ServiceNamespace": "<AppNamespace>",
"ServiceName": "<AppName>",
"Metrics": {
"MeterName": "<AppMeterName>",
"MeterVersion": "<AppMeterVersion>"
}
},
...
Explanation: Since this Extension is primarily aimed at ETL processes, for which sending metrics is essential, the "OpenTelemetry" section as well as all the parameters are required. ServiceNamespace should describe a summarizing border or boundary, and ServiceName should be the concrete and unique name of the application. The name and namespace parameters should be about 10 to 15 characters, the strings should not include any whitespace or special characters.
Meter
Since configuring a meter is required, this section details how to implement the necessary services to report metrics.
Steps:
- Implement a service inheriting from JGUZDVBaseMeter
- Add the service to the service container as singleton
The service registration should look like this:
builder.AddJGUZDVOpenTelemetry();
builder.Services.AddSingleton<MeterContainer>();
MeterContainer should look something like this:
public class MeterContainer : JGUZDVBaseMeter
{
private readonly Counter<int> _exampleCounter;
public MeterContainer(IOptions<JGUZDVOpenTelemetryOptions> 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 | Versions 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. |
-
net9.0
- Azure.Monitor.OpenTelemetry.Exporter (>= 1.3.0)
- Microsoft.Extensions.Hosting (>= 9.0.0)
- OpenTelemetry.Extensions.Hosting (>= 1.11.2)
- OpenTelemetry.Instrumentation.Http (>= 1.11.1)
NuGet packages (2)
Showing the top 2 NuGet packages that depend on JGUZDV.Extensions.OpenTelemetry:
| Package | Downloads |
|---|---|
|
JGUZDV.JobHost
Host for background jobs using Quartz.net |
|
|
JGUZDV.AspNetCore.Extensions.OpenTelemetry
Opinionated extensions to observe ASP.NET Core applications via Azure Monitor and OpenTelemetry. |
GitHub repositories
This package is not used by any popular GitHub repositories.