JGUZDV.Extensions.OpenTelemetry
1.1.2
dotnet add package JGUZDV.Extensions.OpenTelemetry --version 1.1.2
NuGet\Install-Package JGUZDV.Extensions.OpenTelemetry -Version 1.1.2
<PackageReference Include="JGUZDV.Extensions.OpenTelemetry" Version="1.1.2" />
<PackageVersion Include="JGUZDV.Extensions.OpenTelemetry" Version="1.1.2" />
<PackageReference Include="JGUZDV.Extensions.OpenTelemetry" />
paket add JGUZDV.Extensions.OpenTelemetry --version 1.1.2
#r "nuget: JGUZDV.Extensions.OpenTelemetry, 1.1.2"
#:package JGUZDV.Extensions.OpenTelemetry@1.1.2
#addin nuget:?package=JGUZDV.Extensions.OpenTelemetry&version=1.1.2
#tool nuget:?package=JGUZDV.Extensions.OpenTelemetry&version=1.1.2
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
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": "<AppNamespace>",
"ServiceName": "<AppName>",
"Metrics": {
"MeterName": "<AppMeterName>",
"MeterVersion": "<AppMeterVersion>"
}
},
...
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
If you wish to send metrics for your application follow these steps:
- Configure "OpenTelemetry:UseMetrics" section in appsettings.json
- 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 | net10.0 is compatible. 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. |
-
net10.0
- Azure.Monitor.OpenTelemetry.Exporter (>= 1.9.0)
- Microsoft.Extensions.Hosting (>= 10.0.0)
- OpenTelemetry.Extensions.Hosting (>= 1.19.1)
- OpenTelemetry.Instrumentation.Http (>= 1.19.0)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on JGUZDV.Extensions.OpenTelemetry:
| Package | Downloads |
|---|---|
|
JGUZDV.JobHost
Host for background jobs using Quartz.net |
GitHub repositories
This package is not used by any popular GitHub repositories.