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

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

Open
LeeCampbell opened this issue May 11, 2016 · 0 comments
Open

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

LeeCampbell opened this issue May 11, 2016 · 0 comments
Labels

Comments

@LeeCampbell
Copy link
Collaborator

LeeCampbell commented May 11, 2016

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.

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

No branches or pull requests

1 participant