Skip to content

Commit

Permalink
Set OpenMetrics content header
Browse files Browse the repository at this point in the history
  • Loading branch information
mrueg committed Feb 3, 2023
1 parent 5da24c2 commit b0b4b7b
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion pkg/metricshandler/metrics_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ func (m *MetricsHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
resHeader := w.Header()
var writer io.Writer = w

resHeader.Set("Content-Type", `text/plain; version=`+"0.0.4")
resHeader.Set("Content-Type", `application/openmetrics-text; version=`+"0.0.1"+`; charset=utf-8`)

if m.enableGZIPEncoding {
// Gzip response if requested. Taken from
Expand All @@ -206,6 +206,8 @@ func (m *MetricsHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
}
}

w.Write([]byte("# EOF"))

// In case we gzipped the response, we have to close the writer.
if closer, ok := writer.(io.Closer); ok {
err := closer.Close()
Expand Down

0 comments on commit b0b4b7b

Please sign in to comment.