CoreSystem.Correlation
1.1.0
dotnet add package CoreSystem.Correlation --version 1.1.0
NuGet\Install-Package CoreSystem.Correlation -Version 1.1.0
<PackageReference Include="CoreSystem.Correlation" Version="1.1.0" />
<PackageVersion Include="CoreSystem.Correlation" Version="1.1.0" />
<PackageReference Include="CoreSystem.Correlation" />
paket add CoreSystem.Correlation --version 1.1.0
#r "nuget: CoreSystem.Correlation, 1.1.0"
#:package CoreSystem.Correlation@1.1.0
#addin nuget:?package=CoreSystem.Correlation&version=1.1.0
#tool nuget:?package=CoreSystem.Correlation&version=1.1.0
⚡ CoreSystem.Correlation
Correlation ID propagation middleware for ASP.NET Core.
CoreSystem.Correlation is a lightweight, standalone library that accepts or issues a correlation identifier per request, exposes it via HttpContext.Items, and enriches log scopes with it. It can also be composed with CoreSystem.Observability.
✨ Features
- ✅ Accepts a client-provided correlation header (configurable name)
- ✅ Generates a reliable
Guid-based ID otherwise - ✅ Exposes the ID via
HttpContext.Items[CoreCorrelationConstants.HttpContextItemKey] - ✅ Echoes the ID back in the response headers
- ✅ Enriches log scopes with a
correlationIdproperty - ✅ Input validation (length + character allowlist)
- ✅
IOptions/IConfigurationbinding - ✅ Standalone — no dependency on CoreSystem.Observability
📦 Installation
dotnet add package CoreSystem.Correlation
🚀 Quick Start
Register the services:
var builder = WebApplication.CreateBuilder(args);
builder.Services.AddCoreCorrelation(); // or builder.Services.AddCoreCorrelation(o => o.MaximumLength = 64);
var app = builder.Build();
Add the middleware:
app.UseCoreCorrelationId(); // after UseRouting/UseCors, before endpoints
Read the current ID anywhere in the pipeline:
app.MapGet("/ping", (HttpContext ctx) =>
Results.Ok(ctx.Items[CoreCorrelationConstants.HttpContextItemKey]));
⚙ Configuration
Bind from the Core:Correlation configuration section:
builder.Services.AddCoreCorrelation(builder.Configuration);
| Property | Default | Description |
|---|---|---|
Enabled |
true |
Enables correlation propagation |
HeaderName |
X-Correlation-Id |
Header read from (and written back to) the request |
IncludeInResponse |
true |
Whether the ID is echoed in the response |
MaximumLength |
128 |
Maximum accepted length for a client-provided ID |
🏗 Architecture
Client Request
│
▼
CorrelationIdMiddleware
│
├── validates / generates id
├── context.Items["CoreSystem.CorrelationId"]
├── logger scope (correlationId)
▼
Request pipeline
Each request gets one ID for its whole pipeline. The value flows through HttpContext.Items and log scopes so application code can attach it to logs and downstream calls without HTTP-specific knowledge.
📖 Documentation
The full documentation includes:
- Getting Started
- Configuration
- Log enrichment
- Composing with CoreSystem.Observability
- Architecture
Visit the GitHub repository for the complete documentation.
🤝 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 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 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. |
-
net10.0
- No dependencies.
-
net8.0
- No dependencies.
-
net9.0
- No dependencies.
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
1.1.0: targets net8.0, net9.0 and net10.0. No public API or behavior change; the net9.0 and net10.0 assets are new, and the net8.0 asset is unchanged.