-
Notifications
You must be signed in to change notification settings - Fork 29
Open
Labels
Description
Ideally Web devs should be able to just pull a nuget package and add an attribute to controllers that should be measured.
Potentially an ActionFilterAttibute
could be provided in a standalone ASP specific nuget
public class HistogramAttribute : ActionFilterAttribute
{
private const string StartTimestampKey = "HistogramAttribute.StartTimeStamp";
public override void OnActionExecuting(ActionExecutingContext context)
{
context.HttpContext.Items[StartTimestampKey] = Stopwatch.GetTimestamp();
}
public override void OnActionExecuted(ActionExecutedContext context)
{
var stopTimestamp = Stopwatch.GetTimestamp();
var startTimestamp = (long)context.HttpContext.Items[StartTimestampKey];
var elapsed = stopTimestamp - startTimestamp;
Log.RecordValue(elapsed);
}
}
Ideally this would also integrate with tag, recorder and thread safety support.