git » chasquid » commit 099e2e2

expvarom: Use `application/openmetrics-text` as content type

author Alberto Bertogli
2021-06-11 11:44:46 UTC
committer Alberto Bertogli
2021-06-11 11:48:45 UTC
parent 8c8e64dc2930e2641d014273c136de40dc080495

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 +2 -5

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{}