예제 #1
0
        private void LogRemoteLockerPerfStat()
        {
            var metricsData   = remoteLockerMetrics.Context.DataProvider.CurrentMetricsData;
            var metricsReport = StringReport.RenderMetrics(metricsData, () => new HealthStatus());

            Console.Out.WriteLine(metricsReport);
        }
예제 #2
0
        public Task Invoke(HttpContext context)
        {
            if (_options.MetricsTextEnabled && _options.MetricsTextEndpoint.HasValue && _options.MetricsTextEndpoint == context.Request.Path)
            {
                var content = StringReport.RenderMetrics(_metricsContext.Context.DataProvider.CurrentMetricsData, _metricsContext.HealthStatus);
                return(WriteResponse(context, content, "text/plain"));
            }

            return(_next(context));
        }
예제 #3
0
        public MetricsModule()
            : base(Config.ModulePath ?? "/")
        {
            if (string.IsNullOrEmpty(Config.ModulePath))
            {
                return;
            }

            if (Config.ModuleConfigAction != null)
            {
                Config.ModuleConfigAction(this);
            }

            object[] noCacheHeaders =
            {
                new { Header = "Cache-Control", Value = "no-cache, no-store, must-revalidate" },
                new { Header = "Pragma",        Value = "no-cache"                            },
                new { Header = "Expires",       Value = "0"                                   }
            };

            Get["/"] = _ =>
            {
                if (!this.Request.Url.Path.EndsWith("/"))
                {
                    return(Response.AsRedirect(this.Request.Url.ToString() + "/"));
                }
                var gzip     = AcceptsGzip();
                var response = Response.FromStream(FlotWebApp.GetAppStream(!gzip), "text/html");
                if (gzip)
                {
                    response.WithHeader("Content-Encoding", "gzip");
                }
                return(response);
            };

            Get["/text"] = _ => Response.AsText(StringReport.RenderMetrics(Config.DataProvider.CurrentMetricsData, Config.HealthStatus))
                           .WithHeaders(noCacheHeaders);

            Get["/json"] = _ => Response.AsText(JsonBuilderV1.BuildJson(Config.DataProvider.CurrentMetricsData), "text/json")
                           .WithHeaders(noCacheHeaders);

            Get["/v2/json"] = _ => Response.AsText(JsonBuilderV2.BuildJson(Config.DataProvider.CurrentMetricsData), "text/json")
                              .WithHeaders(noCacheHeaders);

            Get["/ping"] = _ => Response.AsText("pong", "text/plain")
                           .WithHeaders(noCacheHeaders);

            Get["/health"] = _ => GetHealthStatus()
                             .WithHeaders(noCacheHeaders);
        }
        private static Task GetAsHumanReadable(IDictionary <string, object> environment, MetricsDataProvider dataProvider, Func <HealthStatus> healthStatus)
        {
            string text = StringReport.RenderMetrics(dataProvider.CurrentMetricsData, healthStatus);

            return(WriteResponse(environment, text, "text/plain"));
        }
예제 #5
0
        private static void WriteTextMetrics(HttpListenerContext context, MetricsDataProvider metricsDataProvider, Func <HealthStatus> healthStatus)
        {
            var text = StringReport.RenderMetrics(metricsDataProvider.CurrentMetricsData, healthStatus);

            WriteString(context, text, "text/plain");
        }
        public string GenerateReport()
        {
            MetricsData metricsData = this._metricsContext.DataProvider.CurrentMetricsData;

            return(StringReport.RenderMetrics(metricsData, HealthChecks.GetStatus));
        }