From 099e2e2269d8bc7b315dce596b4b92fdf46555f2 Mon Sep 17 00:00:00 2001 From: Alberto Bertogli Date: Fri, 11 Jun 2021 12:44:46 +0100 Subject: [PATCH] expvarom: Use `application/openmetrics-text` as content type The openmetrics proposed standard says we should use the `application/openmetrics-text` content type when exporting the metrics. Currently we use `text/plain` for backwards compatibility with Prometheus, but the new content type is apparently supported since 2018, so it should be safe to update to match the current proposed standard. --- internal/expvarom/expvarom.go | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/internal/expvarom/expvarom.go b/internal/expvarom/expvarom.go index d9d00a4..3457557 100644 --- a/internal/expvarom/expvarom.go +++ b/internal/expvarom/expvarom.go @@ -53,11 +53,8 @@ var ( // MetricsHandler implements an http.HandlerFunc which serves the registered // metrics, using the OpenMetrics text-based format. func MetricsHandler(w http.ResponseWriter, r *http.Request) { - w.Header().Set("Content-Type", "text/plain; version=0.0.4") - - // Update to this once it's standard and Prometheus and other ingesters - // can handle this. - //w.Header().Set("Content-Type", "application/openmetrics-text; version=1.0.0; charset=utf-8") + w.Header().Set("Content-Type", + "application/openmetrics-text; version=1.0.0; charset=utf-8") vars := []exportedVar{} ignored := []string{}