ApplicationInsights.OwinExtensions.HttpRequestTrackingMiddleware.Invoke C# (CSharp) Method

Invoke() public method

public Invoke ( IOwinContext context ) : System.Threading.Tasks.Task
context IOwinContext
return System.Threading.Tasks.Task
        public override async Task Invoke(IOwinContext context)
        {
            var method = context.Request.Method;
            var path = context.Request.Path.ToString();
            var uri = context.Request.Uri;

            var requestStartDate = DateTimeOffset.Now;
            var stopWatch = new Stopwatch();
            stopWatch.Start();

            try
            {
                await Next.Invoke(context);
            }
            finally
            {
                stopWatch.Stop();
                if (ShouldTraceRequest(context))
                    TraceRequest(method, path, uri, context.Response.StatusCode, requestStartDate, stopWatch.Elapsed);
            }
        }