GoatFam.OpenTelemetryDistroExtension
1.0.0
dotnet add package GoatFam.OpenTelemetryDistroExtension --version 1.0.0
NuGet\Install-Package GoatFam.OpenTelemetryDistroExtension -Version 1.0.0
<PackageReference Include="GoatFam.OpenTelemetryDistroExtension" Version="1.0.0" />
<PackageVersion Include="GoatFam.OpenTelemetryDistroExtension" Version="1.0.0" />
<PackageReference Include="GoatFam.OpenTelemetryDistroExtension" />
paket add GoatFam.OpenTelemetryDistroExtension --version 1.0.0
#r "nuget: GoatFam.OpenTelemetryDistroExtension, 1.0.0"
#:package GoatFam.OpenTelemetryDistroExtension@1.0.0
#addin nuget:?package=GoatFam.OpenTelemetryDistroExtension&version=1.0.0
#tool nuget:?package=GoatFam.OpenTelemetryDistroExtension&version=1.0.0
OpenTelemetryDistroExtension
A .NET 8.0 and .NET 10.0 library that simplifies the integration of OpenTelemetry with Azure Monitor.
Features
- Easy OpenTelemetry configuration with Azure Monitor - Streamlined setup with minimal configuration code to enable Azure Monitor telemetry collection
- Support for managed identity authentication - Authenticate to Azure Monitor using managed identities without storing connection strings or credentials
- Configurable sampling rates - Control telemetry volume and costs with flexible sampling configuration for traces and metrics
- Live metrics support - Enable real-time application monitoring through Azure Application Insights live metrics stream
- Custom resource attributes for service identification - Add service name, version, and environment tags for better telemetry organization and filtering
Getting Started
Prerequisites
- .NET 10.0 SDK (required to build this package from source)
- Azure subscription with Application Insights resource
- Azure.Monitor.OpenTelemetry.Exporter library (included as dependency)
Installation
Install the NuGet package in your project:
dotnet add package OpenTelemetryDistroExtension
Or add it via Package Manager:
Install-Package OpenTelemetryDistroExtension
For local development, reference the project directly:
<ProjectReference Include="..\..\src\OpenTelemetryDistroExtension\OpenTelemetryDistroExtension.csproj" />
Configuration
Add OpenTelemetry configuration to your appsettings.json:
{
"AIMonitor": {
"ConnectionString": "InstrumentationKey=your-instrumentation-key;IngestionEndpoint=https://your-region.in.applicationinsights.azure.com/",
"ServiceName": "YourServiceName",
"ServiceVersion": "1.0.0",
"Environment": "Production",
"SamplingRatio": 1.0
}
}
Configuration Options
- ConnectionString: Application Insights connection string (required)
- ServiceName: Name of your service for telemetry identification
- ServiceVersion: Version of your service
- Environment: Deployment environment (Development, Staging, Production)
- SamplingRatio: Sampling rate from 0.0 to 1.0 (1.0 = 100% sampling)
Registration
Register OpenTelemetry in your Program.cs:
using OpenTelemetryDistroExtension.Extensions;
var builder = WebApplication.CreateBuilder(args);
// Add OpenTelemetry with Azure Monitor
builder.Services.AddAzureMonitorOpenTelemetry(builder.Configuration);
var app = builder.Build();
Basic Usage
Once registered, OpenTelemetry automatically collects:
- HTTP requests - Incoming and outgoing HTTP calls
- Dependencies - Database calls, Redis operations, Azure SDK calls
- Exceptions - Unhandled exceptions and errors
- Custom traces - Your application's trace data
Custom Instrumentation
using System.Diagnostics;
public class OrderService
{
private static readonly ActivitySource ActivitySource = new("MyApp.OrderService");
public async Task ProcessOrderAsync(string orderId)
{
// Create a custom span
using var activity = ActivitySource.StartActivity("ProcessOrder");
activity?.SetTag("order.id", orderId);
try
{
// Your business logic
await ValidateOrderAsync(orderId);
await ChargePaymentAsync(orderId);
await ShipOrderAsync(orderId);
activity?.SetTag("order.status", "completed");
}
catch (Exception ex)
{
activity?.SetStatus(ActivityStatusCode.Error, ex.Message);
throw;
}
}
}
Sampling Configuration
Control telemetry volume by adjusting the sampling ratio:
{
"AIMonitor": {
"SamplingRatio": 0.1 // 10% sampling for production to reduce costs
}
}
1.0= 100% sampling (all telemetry collected)0.5= 50% sampling (half of telemetry collected)0.1= 10% sampling (recommended for high-traffic production)
Managed Identity Support
For Azure-hosted applications, use managed identity instead of connection strings:
{
"AIMonitor": {
"ConnectionString": "",
"ServiceName": "YourServiceName",
"ClientId": "your-managed-identity-client-id"
}
}
Configure the extension method to use managed identity:
builder.Services.AddAzureMonitorOpenTelemetryWithManagedIdentity(builder.Configuration);
Viewing Telemetry
After configuration, telemetry data appears in Azure Portal:
- Navigate to your Application Insights resource
- View Live Metrics for real-time monitoring
- Check Transaction Search for individual requests
- Use Application Map to visualize dependencies
- Create custom queries in Logs using KQL
Documentation
For detailed patterns and examples:
- docs/coding-patterns.md - OpenTelemetry patterns
- docs/sample-applications.md - Integration examples
- examples/ArticleManagementAPI - Working implementation
License
This project is licensed under the MIT License.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. 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 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. |
| .NET Core | netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
| .NET Standard | netstandard2.1 is compatible. |
| MonoAndroid | monoandroid was computed. |
| MonoMac | monomac was computed. |
| MonoTouch | monotouch was computed. |
| Tizen | tizen60 was computed. |
| Xamarin.iOS | xamarinios was computed. |
| Xamarin.Mac | xamarinmac was computed. |
| Xamarin.TVOS | xamarintvos was computed. |
| Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.1
- Azure.Identity (>= 1.12.0)
- Azure.Monitor.OpenTelemetry.AspNetCore (>= 1.2.0)
- Microsoft.Extensions.DependencyInjection (>= 8.0.0)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 8.0.0)
- Microsoft.Extensions.Options.ConfigurationExtensions (>= 8.0.0)
-
net10.0
- Azure.Identity (>= 1.12.0)
- Azure.Monitor.OpenTelemetry.AspNetCore (>= 1.2.0)
- Microsoft.Extensions.DependencyInjection (>= 8.0.0)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 8.0.0)
- Microsoft.Extensions.Options.ConfigurationExtensions (>= 8.0.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 1.0.0 | 119 | 5/24/2026 |