Muonroi.Observability 1.0.0-alpha.16

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

Muonroi.Observability

OpenTelemetry tracing, metrics, and structured Serilog logging wired for tenant-aware Muonroi services in a single AddObservability call.

NuGet License: Apache 2.0

This package bootstraps OpenTelemetry (OTLP traces + metrics) and Serilog (console, file, OTLP sink) for any Muonroi service. It enriches every trace span and log event with the current tenant ID, user ID, and correlation ID from ISystemExecutionContextAccessor. Other Muonroi packages publish their ActivitySource and Meter names through the ITelemetryDescriptor contract; AddObservability discovers all registered descriptors at startup and wires them automatically — no per-package plumbing required.

Installation

dotnet add package Muonroi.Observability --prerelease

Quick Start

Register observability in Program.cs (or Startup.cs):

using Muonroi.Observability;

var builder = WebApplication.CreateBuilder(args);

// Wire OTel tracing + metrics (reads "OpenTelemetry" config section)
builder.Services.AddObservability(builder.Configuration);

// Wire Serilog with tenant/correlation enrichment
builder.Host.UseSerilog((ctx, services, cfg) =>
    MSerilogAction.Configure(ctx, services, cfg, useConsole: true));

appsettings.json:

{
  "OpenTelemetry": {
    "ServiceName": "my-service",
    "OtlpEndpoint": "http://localhost:4317"
  },
  "Serilog": {
    "MinimumLevel": { "Default": "Information" },
    "OpenTelemetry": {
      "Endpoint": "http://localhost:4317",
      "Protocol": "Grpc"
    },
    "File": {
      "Path": "logs/service-.json"
    }
  }
}

Features

  • Single-call setupAddObservability configures ASP.NET Core, HTTP client, gRPC, MassTransit, and runtime instrumentation in one call.
  • Tenant-aware spansTenantActivityEnricher stamps tenant.id on every Activity via ISystemExecutionContextAccessor.
  • Tenant-aware logsTenantIdEnricher appends TenantId, UserId, CorrelationId, and SourceType Serilog properties.
  • Auto-discovery of package descriptors — any ITelemetryDescriptor implementation found in loaded assemblies has its ActivitySourceNames and MeterNames registered automatically.
  • Central ecosystem meterMuonroiMetrics exposes muonroi.guard.violations, muonroi.exception.total, and muonroi.retry.attempts counters on the Muonroi.Ecosystem.Core meter.
  • Compat telemetry helpers — self-contained ActivitySource + metric helpers for gRPC (GrpcRuntimeTelemetry), message bus (MessageBusRuntimeTelemetry), and distributed cache (DistributedCacheRuntimeTelemetry) avoid cross-package circular references.
  • Serilog sinks — console (opt-in), JSON file (rolling), and OTLP; all configured from IConfiguration.
  • Exception taggingMuonroiTraceProcessor.TagException(activity, ex) stamps exception.category and exception.error_code from MException onto the active span.

Configuration

OpenTelemetryConfigs (section "OpenTelemetry")

Property Type Description
ServiceName string? Service name reported to the OTel backend. Defaults to "MuonroiService" when null.
OtlpEndpoint string? OTLP endpoint URI. Traces and metrics are exported only when this is non-empty.

Serilog sinks (via MSerilogAction.Configure)

MSerilogAction.Configure reads two optional sub-sections:

Section Key fields
Serilog:OpenTelemetry Endpoint (URI), Protocol (Grpc or Http/HttpProtobuf), ResourceAttributes (comma-separated key=value pairs)
Serilog:File Path (file path; directory is created automatically)

All standard Serilog configuration keys (minimum levels, filters, etc.) are also read from IConfiguration via ReadFrom.Configuration.

API Reference

Type Purpose
OtelSetup.AddObservability(services, configuration) Extension method — registers OTel tracing, metrics, and TenantIdEnricher.
MSerilogAction.Configure(ctx, services, cfg, useConsole) Configures Serilog sinks and enrichers for UseSerilog.
OpenTelemetryConfigs POCO bound from the "OpenTelemetry" config section.
TenantIdEnricher Serilog ILogEventEnricher — adds TenantId, UserId, CorrelationId, SourceType.
MuonroiMetrics Static class exposing the Muonroi.Ecosystem.Core Meter and ecosystem-wide counters.
MuonroiTraceProcessor OTel BaseProcessor<Activity> — call TagException(activity, ex) to annotate spans with MException details.
GrpcRuntimeTelemetry Compat helper: ActivitySource + TrackRequest(...) for gRPC spans/metrics.
MessageBusRuntimeTelemetry Compat helper: ActivitySource + TrackOperation(...) for message-bus spans/metrics.
DistributedCacheRuntimeTelemetry Compat helper: ActivitySource + TrackOperation(...) for cache spans/metrics.
MLogEntry Structured log entry model with tenant, correlation, elapsed time, and error code fields.
ILogSanitizer / LogSanitizer Redacts sensitive fields from a log data dictionary before emission.
BootstrapMethod Enum controlling bootstrap-phase logging behavior (Silent, Failure, None).

Compatibility

  • Target framework: net8.0
  • License: Apache-2.0 (OSS)

License

Apache-2.0. See LICENSE-APACHE.

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 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 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 (4)

Showing the top 4 NuGet packages that depend on Muonroi.Observability:

Package Downloads
Muonroi.Resilience

Polly-based resilience patterns for Muonroi: retry, circuit breaker, timeout, and bulkhead policies with OTel integration.

Muonroi.BuildingBlock.All

Metapackage for Muonroi Building Block - Includes all sub-packages for a complete infrastructure setup.

Muonroi.Grpc

Package Description

Muonroi.Messaging.MassTransit

Package Description

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.0-alpha.16 31 6/22/2026
1.0.0-alpha.15 123 5/31/2026
1.0.0-alpha.14 117 5/15/2026
1.0.0-alpha.13 89 5/2/2026
1.0.0-alpha.12 86 4/2/2026
1.0.0-alpha.11 128 4/2/2026
1.0.0-alpha.9 68 3/30/2026
1.0.0-alpha.8 154 3/28/2026
1.0.0-alpha.7 74 3/27/2026
1.0.0-alpha.5 59 3/27/2026
1.0.0-alpha.4 64 3/27/2026
1.0.0-alpha.3 69 3/27/2026
1.0.0-alpha.2 71 3/26/2026
1.0.0-alpha.1 73 3/8/2026