diff --git a/prometheus/promhttp/http.go b/prometheus/promhttp/http.go index a9c4819c4..09b8d2fbe 100644 --- a/prometheus/promhttp/http.go +++ b/prometheus/promhttp/http.go @@ -160,15 +160,11 @@ func HandlerForTransactional(reg prometheus.TransactionalGatherer, opts HandlerO } var contentType expfmt.Format - if req.Header != nil { - fmt.Println("NEGOTIATE content type received: ", req.Header) - } if opts.EnableOpenMetrics { contentType = expfmt.NegotiateIncludingOpenMetrics(req.Header) } else { contentType = expfmt.Negotiate(req.Header) } - fmt.Println("NEGOTIATE deduced content type: ", contentType) header := rsp.Header() header.Set(contentTypeHeader, string(contentType)) @@ -211,7 +207,6 @@ func HandlerForTransactional(reg prometheus.TransactionalGatherer, opts HandlerO } for _, mf := range mfs { - // This is the place where the metric family is getting escaped on the receive side. if handleError(enc.Encode(mf)) { return } diff --git a/prometheus/push/push.go b/prometheus/push/push.go index b2c32f429..e524aa130 100644 --- a/prometheus/push/push.go +++ b/prometheus/push/push.go @@ -109,7 +109,7 @@ func New(url, job string) *Pusher { gatherers: prometheus.Gatherers{reg}, registerer: reg, client: &http.Client{}, - expfmt: expfmt.FmtProtoDelim, + expfmt: expfmt.NewFormat(expfmt.TypeProtoDelim), } } diff --git a/prometheus/push/push_test.go b/prometheus/push/push_test.go index f90740853..d30d17550 100644 --- a/prometheus/push/push_test.go +++ b/prometheus/push/push_test.go @@ -84,7 +84,7 @@ func TestPush(t *testing.T) { } buf := &bytes.Buffer{} - enc := expfmt.NewEncoder(buf, expfmt.FmtProtoDelim) + enc := expfmt.NewEncoder(buf, expfmt.NewFormat(expfmt.TypeProtoDelim)) for _, mf := range mfs { if err := enc.Encode(mf); err != nil { diff --git a/prometheus/registry_test.go b/prometheus/registry_test.go index dca36fe58..61fc1c5cb 100644 --- a/prometheus/registry_test.go +++ b/prometheus/registry_test.go @@ -92,7 +92,7 @@ func testHandler(t testing.TB) { }, } externalBuf := &bytes.Buffer{} - enc := expfmt.NewEncoder(externalBuf, expfmt.FmtProtoDelim) + enc := expfmt.NewEncoder(externalBuf, expfmt.NewFormat(expfmt.TypeProtoDelim)) if err := enc.Encode(externalMetricFamily); err != nil { t.Fatal(err) } @@ -162,7 +162,7 @@ metric: < }, } buf := &bytes.Buffer{} - enc = expfmt.NewEncoder(buf, expfmt.FmtProtoDelim) + enc = expfmt.NewEncoder(buf, expfmt.NewFormat(expfmt.TypeProtoDelim)) if err := enc.Encode(expectedMetricFamily); err != nil { t.Fatal(err) } @@ -361,7 +361,7 @@ collected metric "broken_metric" { label: label: label: label: label: label: label: label: label: label: label: label: label: label: label: label: label: label: label: