stevejgordon / CorrelationId

An ASP.NET Core middleware component which synchronises a correlation ID for cross API request logging.
MIT License
558 stars 106 forks source link

Correlation ID Context #1

Closed stevejgordon closed 6 years ago

stevejgordon commented 7 years ago

Currently the correlation ID is only exposed via the existing HttpContext.TraceIdentifier. This requires either access to the HttpContext or an IHttpContextAccessor to be able to get to the correlation ID.

I'm considering creating a custom "CorrelationContext" which will be available through DI so that the correlation ID can be more easily exposed in classes that don't already have easy access to HttpContext.

glaxaco commented 6 years ago

I accomplished essentially the same thing by passing in a simple Func argument to the constructor of the class that is the client to another API to which I wanted to pass the correlation ID. That function is then passed in startup; the implementation is simply httpContextAccessor.HttpContext.TraceIdentifier.

Franklin89 commented 6 years ago

@stevejgordon Do you have any time to implement this at some point soon?

stevejgordon commented 6 years ago

@Franklin89 Still thinking about it, just haven't had the time as yet.

stevejgordon commented 6 years ago

This work is completed and available since v2.0.0 https://github.com/stevejgordon/CorrelationId/releases/tag/rel%2F2.0.0