I-Synergy.Framework.OpenTelemetry 2025.10527.12202.4-preview

Prefix Reserved
This is a prerelease version of I-Synergy.Framework.OpenTelemetry.
There is a newer prerelease version of this package available.
See the version list below for details.
dotnet add package I-Synergy.Framework.OpenTelemetry --version 2025.10527.12202.4-preview
                    
NuGet\Install-Package I-Synergy.Framework.OpenTelemetry -Version 2025.10527.12202.4-preview
                    
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="I-Synergy.Framework.OpenTelemetry" Version="2025.10527.12202.4-preview" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="I-Synergy.Framework.OpenTelemetry" Version="2025.10527.12202.4-preview" />
                    
Directory.Packages.props
<PackageReference Include="I-Synergy.Framework.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 I-Synergy.Framework.OpenTelemetry --version 2025.10527.12202.4-preview
                    
#r "nuget: I-Synergy.Framework.OpenTelemetry, 2025.10527.12202.4-preview"
                    
#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.
#addin nuget:?package=I-Synergy.Framework.OpenTelemetry&version=2025.10527.12202.4-preview&prerelease
                    
Install as a Cake Addin
#tool nuget:?package=I-Synergy.Framework.OpenTelemetry&version=2025.10527.12202.4-preview&prerelease
                    
Install as a Cake Tool

OpenTelemetry Integration Guide

Overview

The I-Synergy.Framework provides a flexible OpenTelemetry integration that separates instrumentation configuration from exporter configuration. This separation allows for cleaner code organization and better maintainability.

Key Concepts

  • Instrumentation: Defines what to collect (which libraries, frameworks, or custom sources to monitor)
  • Exporters: Defines where to send the collected telemetry data (console, OTLP endpoint, Azure Monitor, etc.)

Architecture

The OpenTelemetry integration in I-Synergy.Framework consists of:

  • ITelemetryProvider interface that defines the contract
  • OpenTelemetryProvider implementation
  • Extension methods for different provider builders (Tracer, Meter, Logger)

Usage Guide

Basic Setup

// In Program.cs or Startup.cs
builder.Logging.AddOpenTelemetry(
    builder.Configuration,
    builder.Environment,
    infoService,
    "Telemetry",
    tracerInstrumentationAction: ConfigureTracingInstrumentation,
    tracerExportersAction: ConfigureTracingExporters,
    meterInstrumentationAction: ConfigureMetricsInstrumentation,
    meterExportersAction: ConfigureMetricsExporters,
    loggerInstrumentationAction: ConfigureLoggingInstrumentation,
    loggerExportersAction: ConfigureLoggingExporters);

Instrumentation Actions

Instrumentation actions should configure what telemetry data to collect.
These actions should add sources, configure sampling, and set up instrumentation for specific libraries or frameworks.

private static void ConfigureTracingInstrumentation(TracerProviderBuilder builder)
{
    // Add sources to collect data from
    builder.AddSource("MyApplicationName");
    
    // Add instrumentation for specific libraries
    builder.AddHttpClientInstrumentation(opts => 
    {
        opts.RecordException = true;
        opts.EnrichWithException = (activity, exception) =>
        {
            activity.SetTag("error.type", exception.GetType().Name);
            activity.SetTag("error.message", exception.Message);
        };
    });
    
    // Add ASP.NET Core instrumentation
    builder.AddAspNetCoreInstrumentation();
}

Exporter Actions

Exporter actions should configure where to send the collected telemetry data.
These actions should add exporters to different backends or services.

private static void ConfigureTracingExporters(TracerProviderBuilder builder)
{
    // Add Azure Monitor exporter
    builder.AddAzureMonitorTraceExporter(options =>
    {
        options.ConnectionString = "your-connection-string";
    });
    
    // Add Jaeger exporter
    builder.AddJaegerExporter(options =>
    {
        options.AgentHost = "localhost";
        options.AgentPort = 6831;
    });
}

Integration Examples

Azure Monitor Integration
builder.Logging.AddOpenTelemetry(
    builder.Configuration,
    builder.Environment,
    infoService,
    "Telemetry",
    tracerInstrumentationAction: builder =>
    {
        builder.AddSource(infoService.ProductName);
        builder.AddHttpClientInstrumentation();
    },
    tracerExportersAction: builder =>
    {
        var connectionString = builder.Configuration["Telemetry:ConnectionString"];
        if (!string.IsNullOrEmpty(connectionString))
        {
            builder.AddAzureMonitorTraceExporter(options =>
            {
                options.ConnectionString = connectionString;
            });
        }
    },
    meterExportersAction: builder =>
    {
        var connectionString = builder.Configuration["Telemetry:ConnectionString"];
        if (!string.IsNullOrEmpty(connectionString))
        {
            builder.AddAzureMonitorMetricExporter(options =>
            {
                options.ConnectionString = connectionString;
            });
        }
    },
    loggerExportersAction: builder =>
    {
        var connectionString = builder.Configuration["Telemetry:ConnectionString"];
        if (!string.IsNullOrEmpty(connectionString))
        {
            builder.AddOpenTelemetry(options =>
            {
                options.AddAzureMonitorLogExporter(o => 
                    o.ConnectionString = connectionString);
            });
        }
    });
Sentry Integration
builder.Logging.AddOpenTelemetry(
    builder.Configuration,
    builder.Environment,
    infoService,
    "Telemetry",
    tracerInstrumentationAction: builder =>
    {
        builder.AddSource(infoService.ProductName);
        builder.AddSentry();

        SentrySdk.Init(options =>
        {
            builder.Configuration.GetSection("Telemetry").Bind(options);
            options.Environment = builder.Environment.EnvironmentName;
            options.Debug = builder.Environment.IsDevelopment();
            options.ServerName = infoService.ProductName;
            options.Release = infoService.ProductVersion.ToString();
            options.UseOpenTelemetry();
        });
    });

Advanced Configuration

Manual Instrumentation

For manual instrumentation, you can inject and use the ActivitySource that's registered by the framework:

public class MyService
{
    private readonly ActivitySource _activitySource;

    public MyService(ActivitySource activitySource)
    {
        _activitySource = activitySource;
    }

    public void DoSomething()
    {
        using var activity = _activitySource.StartActivity("DoSomething");
        activity?.SetTag("custom.tag", "value");
        
        // Your code here
    }
}

Custom Resource Attributes

You can add custom resource attributes through the OpenTelemetryOptions:

{
  "Telemetry": {
    "CustomAttributes": {
      "deployment.region": "WestEurope",
      "service.team": "MyTeam"
    }
  }
}

These attributes will be added to all telemetry data sent from your application.

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  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 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 (6)

Showing the top 5 NuGet packages that depend on I-Synergy.Framework.OpenTelemetry:

Package Downloads
I-Synergy.Framework.AspNetCore

I-Synergy Framework AspNetCore

I-Synergy.Framework.UI

I-Synergy UI Framework for Windows, Linux, Android and WebAssembly

I-Synergy.Framework.UI.WPF

I-Synergy UI Framework for WPF

I-Synergy.Framework.UI.WinUI

I-Synergy UI Framework for WinUI

I-Synergy.Framework.OpenTelemetry.Sentry

I-Synergy Framework OpenTelemetry for Sentry

GitHub repositories

This package is not used by any popular GitHub repositories.