public static async Task WritePrometheusResultText(HttpContext context, HealthReport report, bool alwaysReturnHttp200Ok) { var instance = new PrometheusResponseWriter(); instance.WriteMetricsFromHealthReport(report); context.Response.ContentType = ContentType; if (alwaysReturnHttp200Ok) { context.Response.StatusCode = StatusCodes.Status200OK; } await instance.Registry.CollectAndExportAsTextAsync(context.Response.Body, context.RequestAborted); }
#pragma warning disable IDE1006 // Naming Styles public static async Task WritePrometheusResultText(HttpContext context, HealthReport report, bool alwaysReturnHttp200Ok) //TODO: change public API #pragma warning restore IDE1006 // Naming Styles { var instance = new PrometheusResponseWriter(); instance.WriteMetricsFromHealthReport(report); context.Response.ContentType = CONTENT_TYPE; if (alwaysReturnHttp200Ok) { context.Response.StatusCode = StatusCodes.Status200OK; } await instance.Registry.CollectAndExportAsTextAsync(context.Response.Body, context.RequestAborted); }
public static async Task WritePrometheusResultText(HttpContext context, HealthReport report, bool alwaysReturnHttp200Ok) { var instance = new PrometheusResponseWriter(); instance.WriteMetricsFromHealthReport(report); using (var resultStream = CollectionToStreamWriter(instance.Registry)) { var content = await new StreamContent(resultStream) .ReadAsStringAsync(); context.Response.ContentType = ContentType; if (alwaysReturnHttp200Ok) { context.Response.StatusCode = StatusCodes.Status200OK; } await context.Response.WriteAsync(content, Encoding.UTF8); } }