示例#1
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="config"></param>
 /// <param name="path"></param>
 /// <param name="encoding"></param>
 /// <param name="reportConfig"></param>
 /// <returns></returns>
 public static MetricsEndpointReports WithPrometheusEndpointReport(
     this MetricsEndpointReports config,
     string path,
     Encoding encoding,
     PrometheusReportConfig reportConfig = null)
 {
     reportConfig = reportConfig ?? new PrometheusReportConfig();
     return(config.WithEndpointReport(path, (d, h, c) => new MetricsEndpointResponse(PrometheusReport.RenderMetrics(d, h, reportConfig), "text/plain", encoding)));
 }
示例#2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="currentMetricsData"></param>
        /// <param name="healthStatus"></param>
        /// <param name="config"></param>
        /// <returns></returns>
        public static string RenderMetrics(
            MetricsData currentMetricsData,
            Func <HealthStatus> healthStatus,
            PrometheusReportConfig config)
        {
            var report = new PrometheusReport(config);

            report.RunReport(currentMetricsData, healthStatus, CancellationToken.None);
            return(report._reportText.ToString());
        }
示例#3
0
 private PrometheusReport(PrometheusReportConfig config)
 {
     _config     = config;
     _reportText = new StringBuilder();
 }
示例#4
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="config"></param>
        /// <param name="path"></param>
        /// <param name="reportConfig"></param>
        /// <returns></returns>
        public static MetricsEndpointReports WithPrometheusEndpointReport(this MetricsEndpointReports config, string path = "prometheus", PrometheusReportConfig reportConfig = null)
        {
            Encoding utf8WithoutBom = new UTF8Encoding(false);

            return(WithPrometheusEndpointReport(config, path, utf8WithoutBom, reportConfig));
        }