You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Dec 18, 2018. It is now read-only.
It would be easiest to use Kestrel's identifier, but we already have a well formatted request identifier, so changing to a new format isn't an option. Setting the trace identifier on the HttpContext isn't particularly helpful for logging because the request start scope was started before any middleware is called, so all logs use the traceidentifer set by Kestrel. We have to wrap our requests with a using and a logging scope to get the correlation we need. This doesn't always work, though, if there are errors before that part of the pipeline is reached.
I've not been able to figure out how to tell Kestrel to use a different implementation. It's possible that I'm missing something obvious but I've looked through the code for a while and tried a bunch of different things, no dice.
I would prefer not to fork and hack it. I think this feature would be generally useful, it can probably be done in a way that doesn't impacg perf, as the existing implementation is already pay-to-play.
The text was updated successfully, but these errors were encountered:
This should be moved to aspnet/Hosting. All features are settable on the HttpContext you just need to be able to set it before the logging scope is created (which happens in hosting). You might consider making your own IHttpContextFactory.
publicclassMyHttpContextFactory:IHttpContextFactory{privatereadonlyHttpContextFactory_factory;publicMyHttpContextFactory(IOptions<FormOptions>options){// We're using the default implementation._factory=newHttpContextFactory(options);}publicHttpContextCreate(IFeatureCollectionfeatureCollection){varcontext=_factory.Create(featureCollection);context.TraceIdentifier="MyThing";// Replace this with your own logicreturncontext;}publicvoidDispose(HttpContexthttpContext){_factory.Dispose(httpContext);}}
It would be easiest to use Kestrel's identifier, but we already have a well formatted request identifier, so changing to a new format isn't an option. Setting the trace identifier on the HttpContext isn't particularly helpful for logging because the request start scope was started before any middleware is called, so all logs use the traceidentifer set by Kestrel. We have to wrap our requests with a using and a logging scope to get the correlation we need. This doesn't always work, though, if there are errors before that part of the pipeline is reached.
I've not been able to figure out how to tell Kestrel to use a different implementation. It's possible that I'm missing something obvious but I've looked through the code for a while and tried a bunch of different things, no dice.
I would prefer not to fork and hack it. I think this feature would be generally useful, it can probably be done in a way that doesn't impacg perf, as the existing implementation is already pay-to-play.
The text was updated successfully, but these errors were encountered: