Muonroi.Observability
1.0.0-alpha.16
dotnet add package Muonroi.Observability --version 1.0.0-alpha.16
NuGet\Install-Package Muonroi.Observability -Version 1.0.0-alpha.16
<PackageReference Include="Muonroi.Observability" Version="1.0.0-alpha.16" />
<PackageVersion Include="Muonroi.Observability" Version="1.0.0-alpha.16" />
<PackageReference Include="Muonroi.Observability" />
paket add Muonroi.Observability --version 1.0.0-alpha.16
#r "nuget: Muonroi.Observability, 1.0.0-alpha.16"
#:package Muonroi.Observability@1.0.0-alpha.16
#addin nuget:?package=Muonroi.Observability&version=1.0.0-alpha.16&prerelease
#tool nuget:?package=Muonroi.Observability&version=1.0.0-alpha.16&prerelease
Muonroi.Observability
OpenTelemetry tracing, metrics, and structured Serilog logging wired for tenant-aware Muonroi services in a single
AddObservabilitycall.
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 setup —
AddObservabilityconfigures ASP.NET Core, HTTP client, gRPC, MassTransit, and runtime instrumentation in one call. - Tenant-aware spans —
TenantActivityEnricherstampstenant.idon everyActivityviaISystemExecutionContextAccessor. - Tenant-aware logs —
TenantIdEnricherappendsTenantId,UserId,CorrelationId, andSourceTypeSerilog properties. - Auto-discovery of package descriptors — any
ITelemetryDescriptorimplementation found in loaded assemblies has itsActivitySourceNamesandMeterNamesregistered automatically. - Central ecosystem meter —
MuonroiMetricsexposesmuonroi.guard.violations,muonroi.exception.total, andmuonroi.retry.attemptscounters on theMuonroi.Ecosystem.Coremeter. - 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 tagging —
MuonroiTraceProcessor.TagException(activity, ex)stampsexception.categoryandexception.error_codefromMExceptiononto 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)
Related Packages
Muonroi.Core.Abstractions— definesITelemetryDescriptorandISystemExecutionContextAccessorconsumed hereMuonroi.Tenancy.Abstractions— tenant context resolved for span/log enrichmentMuonroi.Governance.Abstractions— license feature gate (FreeTierFeatures.Premium.AuditTrail) checked during registration
License
Apache-2.0. See LICENSE-APACHE.
| Product | Versions 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. |
-
net8.0
- Muonroi.Core.Abstractions (>= 1.0.0-alpha.16)
- Muonroi.Governance.Abstractions (>= 1.0.0-alpha.16)
- Muonroi.Tenancy.Abstractions (>= 1.0.0-alpha.16)
- OpenTelemetry.Exporter.OpenTelemetryProtocol (>= 1.15.3)
- OpenTelemetry.Extensions.Hosting (>= 1.9.0)
- OpenTelemetry.Instrumentation.AspNetCore (>= 1.9.0)
- OpenTelemetry.Instrumentation.GrpcNetClient (>= 1.9.0-beta.1)
- OpenTelemetry.Instrumentation.Http (>= 1.9.0)
- OpenTelemetry.Instrumentation.Runtime (>= 1.9.0)
- Serilog.Enrichers.Span (>= 3.1.0)
- Serilog.Exceptions (>= 8.4.0)
- Serilog.Extensions.Hosting (>= 8.0.0)
- Serilog.Settings.Configuration (>= 8.0.4)
- Serilog.Sinks.Console (>= 6.0.0)
- Serilog.Sinks.File (>= 6.0.0)
- Serilog.Sinks.OpenTelemetry (>= 1.2.0)
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 |