GoatFam.OpenTelemetryDistroExtension 1.0.0

dotnet add package GoatFam.OpenTelemetryDistroExtension --version 1.0.0
                    
NuGet\Install-Package GoatFam.OpenTelemetryDistroExtension -Version 1.0.0
                    
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="GoatFam.OpenTelemetryDistroExtension" Version="1.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="GoatFam.OpenTelemetryDistroExtension" Version="1.0.0" />
                    
Directory.Packages.props
<PackageReference Include="GoatFam.OpenTelemetryDistroExtension" />
                    
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 GoatFam.OpenTelemetryDistroExtension --version 1.0.0
                    
#r "nuget: GoatFam.OpenTelemetryDistroExtension, 1.0.0"
                    
#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 GoatFam.OpenTelemetryDistroExtension@1.0.0
                    
#: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=GoatFam.OpenTelemetryDistroExtension&version=1.0.0
                    
Install as a Cake Addin
#tool nuget:?package=GoatFam.OpenTelemetryDistroExtension&version=1.0.0
                    
Install as a Cake Tool

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:

  1. Navigate to your Application Insights resource
  2. View Live Metrics for real-time monitoring
  3. Check Transaction Search for individual requests
  4. Use Application Map to visualize dependencies
  5. Create custom queries in Logs using KQL

Documentation

For detailed patterns and examples:

License

This project is licensed under the MIT License.

Product 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

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