Muflone.OpenTelemetry 10.1.0

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

Muflone.OpenTelemetry

OpenTelemetry instrumentation for the Muflone CQRS/ES framework. Adds automatic distributed tracing to your command handlers, event handlers, service bus, event bus, and repository — with zero changes to your business logic.

Installation

dotnet add package Muflone.OpenTelemetry

Requirements

Quick Start

Two calls are all you need — one to wire up the OpenTelemetry pipeline and one to decorate your Muflone services:

using Muflone.OpenTelemetry;
using OpenTelemetry.Trace;

var builder = WebApplication.CreateBuilder(args);

// 1. Register your Muflone services as usual
builder.Services.AddMuflone();

// 2. Add OpenTelemetry and enable Muflone instrumentation
builder.Services.AddOpenTelemetry()
    .WithTracing(tracing => tracing
        .AddMufloneInstrumentation()   // registers all Muflone activity sources
        .AddAspNetCoreInstrumentation()
        .AddOtlpExporter());           // or Console, Jaeger, Zipkin, etc.

// 3. Decorate IServiceBus, IEventBus, and IRepository with instrumented wrappers
builder.Services.AddMufloneOpenTelemetry();

That's it. Every command dispatch, event publish, and repository call now produces OpenTelemetry spans with full W3C trace-context propagation.

How It Works

AddMufloneOpenTelemetry() uses the decorator pattern to wrap the concrete IServiceBus, IEventBus, and IRepository registrations you already have in DI. The instrumented decorators:

  • Create Producer spans when sending commands or publishing events
  • Create Consumer spans in handler base classes when processing messages
  • Automatically inject and extract W3C traceparent/tracestate headers via UserProperties
  • Tag every span with messaging.operation, messaging.message_type, and messaging.message_id

AddMufloneInstrumentation() registers all the Muflone activity sources so the OpenTelemetry SDK captures their spans:

Activity Source Covers
Muflone Core activity source
Muflone.CommandHandler Command handler processing
Muflone.DomainEventHandler Domain event handler processing
Muflone.IntegrationEventHandler Integration event handler processing
Muflone.ServiceBus Service bus send operations
Muflone.EventBus Event bus publish operations
Muflone.Repository Repository save/get operations

Full Example

// Program.cs
using Muflone.OpenTelemetry;
using OpenTelemetry.Trace;

var builder = WebApplication.CreateBuilder(args);

// Register your Muflone infrastructure (service bus, event bus, repository, handlers …)
builder.Services.AddMuflone();

// OpenTelemetry + Muflone tracing
builder.Services.AddOpenTelemetry()
    .WithTracing(tracing => tracing
        .AddMufloneInstrumentation()
        .AddAspNetCoreInstrumentation()
        .AddOtlpExporter());

builder.Services.AddMufloneOpenTelemetry();

var app = builder.Build();
app.MapControllers();
app.Run();
// OrderController.cs — no tracing code needed
public class OrderController(IServiceBus serviceBus) : ControllerBase
{
    [HttpPost]
    public async Task<IActionResult> Create(CreateOrderRequest request)
    {
        var command = new CreateOrderCommand(Guid.NewGuid(), request.CustomerId);
        await serviceBus.SendAsync(command);   // automatically traced
        return Accepted();
    }
}

The resulting trace in your backend (Jaeger, Tempo, etc.) will show a single distributed trace spanning the HTTP request, the command dispatch, repository save, event publish, and event handling.

API Reference

AddMufloneInstrumentation()

public static TracerProviderBuilder AddMufloneInstrumentation(
    this TracerProviderBuilder builder)

Registers all Muflone ActivitySource names with the OpenTelemetry TracerProviderBuilder so their spans are captured by configured exporters.

AddMufloneOpenTelemetry()

public static IServiceCollection AddMufloneOpenTelemetry(
    this IServiceCollection services)

Decorates the registered IServiceBus, IEventBus, and IRepository implementations with instrumented wrappers that automatically create spans and propagate trace context. Call this after registering your concrete implementations.

If a given interface is not registered in DI, it is silently skipped — so you only pay for what you use.

InjectTraceContext()

public static void InjectTraceContext(this IMessage message)

Injects the current W3C trace context (traceparent and tracestate) into the message's UserProperties dictionary. This is called automatically by the instrumented decorators but is available if you need manual control.

Trace Propagation

Trace context is propagated via the W3C Trace Context standard:

Key Description
traceparent Trace ID, parent span ID, and trace flags
tracestate Optional vendor-specific trace data

Both values are stored in the message's UserProperties dictionary and are fully compatible with standard OpenTelemetry propagators.

License

MIT License — see LICENSE for details.

Contributing

Contributions are welcome! Please open an issue or pull request on GitHub.

Product 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. 
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
10.1.0 80 3/1/2026
10.1.0-rc1 109 2/12/2026
10.1.0-beta1 80 2/9/2026
10.0.0 110 1/25/2026 10.0.0 is deprecated because it has critical bugs.
10.0.0-beta1 94 1/25/2026