Skip to content

Provide a simple entry point for ASP.NET recording #19

@LeeCampbell

Description

@LeeCampbell

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions