// ReSharper disable UnusedMember.Global
        public async Task Invoke(HttpContext context)
        // ReSharper restore UnusedMember.Global
        {
            _logger.MiddlewareExecuting <MetricsEndpointMiddleware>();

            await _metricsResponseWriter.WriteAsync(context, _metrics.Snapshot.Get(), context.RequestAborted);

            _logger.MiddlewareExecuted <MetricsEndpointMiddleware>();
        }
        // ReSharper disable UnusedMember.Global
        public async Task Invoke(HttpContext context)
        // ReSharper restore UnusedMember.Global
        {
            if (Options.MetricsEndpointEnabled && Options.MetricsEndpoint.IsPresent() && Options.MetricsEndpoint == context.Request.Path)
            {
                Logger.MiddlewareExecuting(GetType());

                context.Response.Headers["Content-Type"] = new[] { _metricsResponseWriter.ContentType };
                context.SetNoCacheHeaders();
                context.Response.StatusCode = (int)HttpStatusCode.OK;

                await _metricsResponseWriter.WriteAsync(context, Metrics.Snapshot.Get(), context.RequestAborted).ConfigureAwait(false);

                Logger.MiddlewareExecuted(GetType());

                return;
            }

            await _next(context);
        }