Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add elapsedMs parameter to the EnrichDiagnosticContext delegate #389

Open
jmenziessmith opened this issue Nov 28, 2024 · 3 comments
Open

Comments

@jmenziessmith
Copy link

Is your feature request related to a problem? Please describe.
I want to use the diagnostic context to log a structured object containing enhanced request information. I would like this to include the elapsed duration, but the value is not accessible outside of the middleware. I believe this is a simple fix, to just include the elapsedMs value as a parameter to the EnrichDiagnosticContext action.

Describe the solution you'd like

RequestLoggingMiddleware.cs#L30

readonly Action<IDiagnosticContext, HttpContext>? _enrichDiagnosticContext; // current
readonly Action<IDiagnosticContext, HttpContext, double>? _enrichDiagnosticContext; // proposed

RequestLoggingMiddleware.cs#L85

_enrichDiagnosticContext?.Invoke(_diagnosticContext, httpContext); // current
_enrichDiagnosticContext?.Invoke(_diagnosticContext, httpContext, elapsedMs); // proposed

Describe alternatives you've considered
n/a

Additional context
n/a

@nblumhardt
Copy link
Member

Thanks for dropping us a line!

How does the duration you want to pass through the IDiagnosticContext differ from the one computed by the middleware?

@jmenziessmith
Copy link
Author

Hi. Thanks for the quick reply.

I don't expect the duration to differ - I would expect the same value. The desire is to be able to access that value when enriching the DiagnoticContext.

@nblumhardt
Copy link
Member

Ah sorry, I see I misunderstood 😅 - thanks for the clarification.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants