Resources/Correlation IDs package (HTTP + jobs)

Correlation IDs package (HTTP + jobs)

A correlation ID contract plus copy/paste ASP.NET Core middleware and an HttpClient handler so correlation survives HTTP and background job boundaries and incidents become one-query diagnosable.

FreeJan 30, 2026
Download

What you get (4 files):

correlation-id-contract.md: The contract every service follows

  • Header name and format
  • Generation and propagation rules
  • What not to do (multiple competing IDs)

📄 AspNetCoreCorrelationIdMiddleware.cs: Inbound request correlation

  • Accepts inbound ID or generates one
  • Adds response header
  • Starts a logging scope with correlation_id

📄 CorrelationIdDelegatingHandler.cs: Outbound propagation for HttpClient

  • Copies correlation ID to downstream calls
  • Preserves existing header if already set
  • Integration hint: register once per HttpClient

📋 README.md: Integration notes

  • Where to wire it in API and worker processes
  • Recommended log fields to make correlation useful
  • Quick verification steps

Quick reference (inline preview):

text
Correlation contract
- If inbound X-Correlation-Id exists: keep it
- Else: generate a new one
- Always: add it to response headers, dependency calls, and job messages
- Always: include correlation_id in every log event that matters

Newsletter

Get the .NET production reliability newsletter

Weekly runbooks, failure patterns, and practical fixes.

No spam. Practical updates only.

We respect your inbox. Unsubscribe anytime.

No spam. Unsubscribe anytime.

Need help implementing this?

I can help you apply this to your systems without the drama.

Work with me

Similar resources

More resources to help you succeed

View all
Canonical: https://matrixtrak.com/resources/correlation-ids-playbook-dotnet