Esempio n. 1
0
        public async Task InvokeAsync(HttpContext context)
        {
            var stopwatch = Stopwatch.StartNew();

            await _next(context);

            stopwatch.Stop();

            var bucketPrefix = CreateBucketPrefix(context);
            var dimensions   = ExtractDimensions(context);

            await Task.WhenAll(
                _statsPublisher.TimingAsync($"{bucketPrefix}.msecs", stopwatch.ElapsedMilliseconds, dimensions),
                _statsPublisher.IncrementAsync($"{bucketPrefix}.{context.Response.StatusCode}", 1, dimensions));
        }
        public async Task InvokeAsync(HttpContext context)
        {
            var stopwatch = Stopwatch.StartNew();

            await next(context);

            stopwatch.Stop();

            var routeData    = context.GetRouteData();
            var bucketPrefix = routeData != null
                ? $"http.{routeData.Values["controller"]}-{routeData.Values["action"]}-{context.Request.Method}"
                : $"http.no-route-data";

            await Task.WhenAll(
                statsPublisher.TimingAsync($"{bucketPrefix}.msecs", stopwatch.ElapsedMilliseconds),
                statsPublisher.IncrementAsync($"{bucketPrefix}.{context.Response.StatusCode}"));
        }