Correlation Ids
Cross-service correlation is handled by automatic W3C
traceparentpropagation (UseW3CTraceContext()), which continues a distributed trace from the incomingtraceparent/tracestateheaders on every transport — see the migration guide.
What remains
ICorrelationId and its log-scope enrichment are still available. WithCorrelationId() attaches a
correlationId value to the logging scope (via ILogger.BeginScope):
.UseLogResult(x => x.WithCorrelationId());
With nothing populating it, ICorrelationId self-generates a GUID per scope — useful as a
per-invocation marker in logs. To populate it from a custom source (e.g. a partner's proprietary
header), register AddCorrelationId() and call ICorrelationId.Set(...) from your own middleware:
app.Use("PartnerCorrelation", resolver => async (context, next) =>
{
var headers = resolver.GetService<IMessageHeadersGetter<MyContext>>();
resolver.GetService<ICorrelationId>().Set(headers.GetHeader(context, "x-partner-request-id"));
await next();
});
Outbound clients can still forward the value: .UseCorrelationId() on an outbound route pipeline
(see Clients — Outbound middleware) stamps the current
ICorrelationId onto the outgoing request's x-correlation-id header.