-
Notifications
You must be signed in to change notification settings - Fork 108
Add timestamp and duration to Diagnostics Source events #261
Add timestamp and duration to Diagnostics Source events #261
Conversation
Hi @avanderhoorn, I'm your friendly neighborhood .NET Foundation Pull Request Bot (You can call me DNFBOT). Thanks for your contribution! The agreement was validated by .NET Foundation and real humans are currently evaluating your PR. TTYL, DNFBOT; |
if (_diagnostics.IsEnabled("Microsoft.AspNetCore.MiddlewareAnalysis.MiddlewareStarting")) | ||
{ | ||
_diagnostics.Write("Microsoft.AspNetCore.MiddlewareAnalysis.MiddlewareStarting", new { name = _middlewareName, httpContext = httpContext, instanceId = _instanceId }); | ||
startTimestamp = Stopwatch.GetTimestamp(); | ||
_diagnostics.Write("Microsoft.AspNetCore.MiddlewareAnalysis.MiddlewareStarting", new { name = _middlewareName, httpContext = httpContext, instanceId = _instanceId, timestamp = startTimestamp }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These lines are getting a tad long - can you wrap them like:
_diagnostics.Write(
"Microsoft.AspNetCore.MiddlewareAnalysis.MiddlewareStarting",
new
{
name = _middlewareName,
httpContext = httpContext,
instanceId = _instanceId,
timestamp = startTimestamp, // and include this trailing comma :)
});
@kichalla please review & merge when you have a chance. |
If users subscribe only to the |
Hi @avanderhoorn, I'm your friendly neighborhood .NET Foundation Pull Request Bot (You can call me DNFBOT). Thanks for your contribution! The agreement was validated by .NET Foundation and real humans are currently evaluating your PR. TTYL, DNFBOT; |
Whoops didn't meant to close... reopend. |
Ok, I've updated things to fix the line breaks. Additionally, I've updated things so that the |
|
Ah yeah I like this fix - I'd like the data to always be accurate, when available. |
Given the precedence of what we have here aspnet/Hosting#543 I'm adding timestamp data to these events - this ensures that everyone is working from the same base data when talking timings.
In addition, I'm adding
duration
to thefinish
events so that consumers only have to subscribe tofinish
events in order to determine what the duration for a given piece of middleware is. This change is localized to the scope of code where we know that we have listeners interested in the result and hence isn't on the primary execution path.