CoreSystem.Observability
1.0.3
See the version list below for details.
dotnet add package CoreSystem.Observability --version 1.0.3
NuGet\Install-Package CoreSystem.Observability -Version 1.0.3
<PackageReference Include="CoreSystem.Observability" Version="1.0.3" />
<PackageVersion Include="CoreSystem.Observability" Version="1.0.3" />
<PackageReference Include="CoreSystem.Observability" />
paket add CoreSystem.Observability --version 1.0.3
#r "nuget: CoreSystem.Observability, 1.0.3"
#:package CoreSystem.Observability@1.0.3
#addin nuget:?package=CoreSystem.Observability&version=1.0.3
#tool nuget:?package=CoreSystem.Observability&version=1.0.3
📊 CoreSystem.Observability
OpenTelemetry and Serilog integration for ASP.NET Core applications on .NET 8
CoreSystem.Observability configures structured logs, distributed traces, metrics,
and health-check endpoints from a single WebApplicationBuilder extension. It
exports telemetry through OTLP/gRPC and supports observability contributions
registered by other CoreSystem modules.
✨ Features
- ✅ Serilog console logging with optional OTLP log export
- ✅ ASP.NET Core, HTTP client, SQL Server, and runtime instrumentation
- ✅ OTLP/gRPC export for traces, metrics, and logs
- ✅ Configurable trace sampling
- ✅ Optional SQL statement capture, disabled by default
- ✅ Custom meters and activity sources contributed by CoreSystem modules
- ✅ Liveness endpoint at
/health - ✅ Readiness endpoint at
/ready - ✅ Invalid or empty OTLP endpoints do not prevent the application from starting
📦 Installation
dotnet add package CoreSystem.Observability
🚀 Quick Start
Register observability before building the application:
var builder = WebApplication.CreateBuilder(args);
builder.AddObservability(
environment: builder.Environment.EnvironmentName,
serviceName: "Orders.Api",
serviceNamespace: "Company.Platform");
var app = builder.Build();
app.UseObservabilityEndpoints();
app.Run();
UseObservabilityEndpoints() enables Serilog request logging and maps the
health endpoints. Place it before endpoint mappings that should be included in
request logging.
⚙️ Configuration
Configure telemetry in the OpenTelemetry section of appsettings.json.
Each signal is disabled unless its Enabled property is true.
{
"OpenTelemetry": {
"Logging": {
"Enabled": true,
"OtlpEndpoint": "http://localhost:4317"
},
"Tracing": {
"Enabled": true,
"OtlpEndpoint": "http://localhost:4317",
"SamplingProbability": 1.0,
"CaptureSqlStatements": false
},
"Metrics": {
"Enabled": true,
"OtlpEndpoint": "http://localhost:4317",
"Meters": [
"Core.Idempotency",
"Core.Resilience"
]
}
}
}
All three signals use OTLP over gRPC. The default endpoint is
http://otel-collector:4317; provide an endpoint reachable from the running
application. An empty or invalid endpoint skips that signal's exporter while
leaving the application running.
Trace sampling
SamplingProbability must be between 0 and 1. Invalid values fall back to
1.0.
SQL statement capture
CaptureSqlStatements is false by default. SQL text can contain sensitive
values, so enable it only after confirming your queries do not expose secrets
or personally identifiable information.
🩺 Health Endpoints
| Endpoint | Purpose | Registered checks |
|---|---|---|
/health |
Liveness probe | None; reports that the process can serve requests. |
/ready |
Readiness probe | All checks registered by IHealthCheckContributor implementations. |
Both endpoints return JSON with the overall status, duration, and individual check details. The health and readiness endpoints are excluded from ASP.NET Core trace instrumentation to reduce telemetry noise.
📊 Telemetry
Traces
Tracing includes ASP.NET Core requests, outgoing HttpClient calls, and SQL
Server client operations. Registered IObservabilityContributor implementations
can add their activity source names to the trace provider.
Metrics
Metrics include ASP.NET Core, HttpClient, and .NET runtime instrumentation.
Add application or CoreSystem meter names through OpenTelemetry:Metrics:Meters.
Logs
Logs use Serilog with console output by default. When logging is enabled and a valid OTLP endpoint is configured, logs are additionally exported through OTLP.
🔌 CoreSystem Integration
CoreSystem modules can contribute their own telemetry and health checks through
the CoreSystem.Observability.Abstractions package. Register those modules
before calling AddObservability so their contributors are included during
observability setup.
builder.Services.AddCoreIdempotency(options =>
{
// Configure the module.
});
builder.AddObservability(
builder.Environment.EnvironmentName,
"Orders.Api",
"Company.Platform");
🛠 Requirements
| Component | Version |
|---|---|
| .NET SDK | 8.0+ |
| ASP.NET Core | 8.0+ |
| OTLP collector or compatible backend | Recommended |
| OTLP gRPC endpoint | Commonly port 4317 |
🤝 Contributing
Issues, discussions, and pull requests are welcome.
📄 License
Released under the MIT License.
| 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
- CoreSystem.Observability.Abstractions (>= 1.0.2)
- Microsoft.Data.SqlClient (>= 7.1.1)
- Microsoft.Extensions.Caching.Abstractions (>= 8.0.0)
- Microsoft.Extensions.Caching.Memory (>= 8.0.1)
- Microsoft.Extensions.Configuration (>= 8.0.0)
- Microsoft.Extensions.Configuration.Abstractions (>= 8.0.0)
- Microsoft.Extensions.Configuration.Binder (>= 8.0.2)
- Microsoft.Extensions.DependencyInjection (>= 8.0.0)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 8.0.2)
- Microsoft.Extensions.Diagnostics.HealthChecks (>= 8.0.32)
- Microsoft.Extensions.Options (>= 8.0.2)
- OpenTelemetry (>= 1.20.0)
- OpenTelemetry.Api (>= 1.20.0)
- OpenTelemetry.Exporter.OpenTelemetryProtocol (>= 1.20.0)
- OpenTelemetry.Extensions.Hosting (>= 1.20.0)
- OpenTelemetry.Instrumentation.AspNetCore (>= 1.20.0)
- OpenTelemetry.Instrumentation.Http (>= 1.20.0)
- OpenTelemetry.Instrumentation.Runtime (>= 1.20.0)
- OpenTelemetry.Instrumentation.SqlClient (>= 1.20.0)
- Serilog.AspNetCore (>= 8.0.3)
- Serilog.Enrichers.Thread (>= 4.0.0)
- Serilog.Sinks.OpenTelemetry (>= 4.2.0)
- System.Configuration.ConfigurationManager (>= 8.0.1)
- System.Security.Cryptography.Pkcs (>= 8.0.2)
- System.Threading.RateLimiting (>= 10.0.10)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
1.0.2: Package-only fix. The 1.0.1 nuspec declared CoreSystem.Observability.Abstractions 1.0.0 because the package was tagged before the central pin was refreshed. This release declares 1.0.1. No code or API changes.
1.0.3: Dependency refresh plus a configuration-binding fix. Dependencies: OpenTelemetry stack 1.19.0 to 1.20.0 (Sdk, Api, Exporter.OpenTelemetryProtocol, Extensions.Hosting and the AspNetCore/Http/Runtime/SqlClient instrumentations); Microsoft.Data.SqlClient 7.1.0 to 7.1.1; System.Security.Cryptography.Pkcs pinned to 8.0.2 to clear a Moderate advisory; CoreSystem.Observability.Abstractions refreshed to 1.0.2 (Microsoft.Extensions.Diagnostics.HealthChecks 8.0.32). Fix: each exporter now binds only its own configuration subsection (OpenTelemetry:Tracing, OpenTelemetry:Metrics, OpenTelemetry:Logging) instead of the whole OpenTelemetry section, and an invalid value no longer aborts startup. Previously a malformed value such as a non-numeric Tracing:SamplingProbability threw InvalidOperationException from AddObservability and prevented the host from starting. Invalid values are now reported through Trace and the affected exporter falls back to its defaults; a valid Enabled flag is still honoured so one bad value cannot silently disable tracing or metrics. No public API changes.