From 55c99d4efd4a313a06815d04090021c4a962d0d1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=A1s=20Pazos?= Date: Mon, 23 Oct 2023 12:19:59 -0300 Subject: [PATCH] fields rewording in handler MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Nicolás Pazos --- storage/remote/write_handler.go | 17 +++++++++-------- web/api/v1/api.go | 4 ++-- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/storage/remote/write_handler.go b/storage/remote/write_handler.go index 0efc0e951..888f85418 100644 --- a/storage/remote/write_handler.go +++ b/storage/remote/write_handler.go @@ -38,17 +38,18 @@ type writeHandler struct { samplesWithInvalidLabelsTotal prometheus.Counter - // experimental feature, new remote write proto format - internFormat bool + // Experimental feature, new remote write proto format + // The handler will accept the new format, but it can still accept the old one + enableRemoteWrite11 bool } // NewWriteHandler creates a http.Handler that accepts remote write requests and // writes them to the provided appendable. -func NewWriteHandler(logger log.Logger, reg prometheus.Registerer, appendable storage.Appendable, internFormat bool) http.Handler { +func NewWriteHandler(logger log.Logger, reg prometheus.Registerer, appendable storage.Appendable, enableRemoteWrite11 bool) http.Handler { h := &writeHandler{ - logger: logger, - appendable: appendable, - internFormat: internFormat, + logger: logger, + appendable: appendable, + enableRemoteWrite11: enableRemoteWrite11, samplesWithInvalidLabelsTotal: prometheus.NewCounter(prometheus.CounterOpts{ Namespace: "prometheus", @@ -68,7 +69,7 @@ func (h *writeHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) { var req *prompb.WriteRequest var reqWithRefs *prompb.WriteRequestWithRefs // TODO-RW11: Need to check headers to decide what version is and what to do - if h.internFormat { + if h.enableRemoteWrite11 { reqWithRefs, err = DecodeReducedWriteRequest(r.Body) } else { req, err = DecodeWriteRequest(r.Body) @@ -80,7 +81,7 @@ func (h *writeHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) { return } - if h.internFormat { + if h.enableRemoteWrite11 { err = h.writeReduced(r.Context(), reqWithRefs) } else { err = h.write(r.Context(), req) diff --git a/web/api/v1/api.go b/web/api/v1/api.go index 86062be07..9e3873aef 100644 --- a/web/api/v1/api.go +++ b/web/api/v1/api.go @@ -254,7 +254,7 @@ func NewAPI( statsRenderer StatsRenderer, rwEnabled bool, otlpEnabled bool, - remoteWriteReducedProto bool, + enableRemoteWrite11 bool, ) *API { a := &API{ QueryEngine: qe, @@ -296,7 +296,7 @@ func NewAPI( } if rwEnabled { - a.remoteWriteHandler = remote.NewWriteHandler(logger, registerer, ap, remoteWriteReducedProto) + a.remoteWriteHandler = remote.NewWriteHandler(logger, registerer, ap, enableRemoteWrite11) } if otlpEnabled { a.otlpWriteHandler = remote.NewOTLPWriteHandler(logger, ap)