mirror of
https://github.com/prometheus/prometheus.git
synced 2025-03-05 20:59:13 -08:00
fields rewording in handler
Signed-off-by: Nicolás Pazos <npazosmendez@gmail.com>
This commit is contained in:
parent
ba3422df1f
commit
55c99d4efd
|
@ -38,17 +38,18 @@ type writeHandler struct {
|
||||||
|
|
||||||
samplesWithInvalidLabelsTotal prometheus.Counter
|
samplesWithInvalidLabelsTotal prometheus.Counter
|
||||||
|
|
||||||
// experimental feature, new remote write proto format
|
// Experimental feature, new remote write proto format
|
||||||
internFormat bool
|
// 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
|
// NewWriteHandler creates a http.Handler that accepts remote write requests and
|
||||||
// writes them to the provided appendable.
|
// 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{
|
h := &writeHandler{
|
||||||
logger: logger,
|
logger: logger,
|
||||||
appendable: appendable,
|
appendable: appendable,
|
||||||
internFormat: internFormat,
|
enableRemoteWrite11: enableRemoteWrite11,
|
||||||
|
|
||||||
samplesWithInvalidLabelsTotal: prometheus.NewCounter(prometheus.CounterOpts{
|
samplesWithInvalidLabelsTotal: prometheus.NewCounter(prometheus.CounterOpts{
|
||||||
Namespace: "prometheus",
|
Namespace: "prometheus",
|
||||||
|
@ -68,7 +69,7 @@ func (h *writeHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||||
var req *prompb.WriteRequest
|
var req *prompb.WriteRequest
|
||||||
var reqWithRefs *prompb.WriteRequestWithRefs
|
var reqWithRefs *prompb.WriteRequestWithRefs
|
||||||
// TODO-RW11: Need to check headers to decide what version is and what to do
|
// 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)
|
reqWithRefs, err = DecodeReducedWriteRequest(r.Body)
|
||||||
} else {
|
} else {
|
||||||
req, err = DecodeWriteRequest(r.Body)
|
req, err = DecodeWriteRequest(r.Body)
|
||||||
|
@ -80,7 +81,7 @@ func (h *writeHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if h.internFormat {
|
if h.enableRemoteWrite11 {
|
||||||
err = h.writeReduced(r.Context(), reqWithRefs)
|
err = h.writeReduced(r.Context(), reqWithRefs)
|
||||||
} else {
|
} else {
|
||||||
err = h.write(r.Context(), req)
|
err = h.write(r.Context(), req)
|
||||||
|
|
|
@ -254,7 +254,7 @@ func NewAPI(
|
||||||
statsRenderer StatsRenderer,
|
statsRenderer StatsRenderer,
|
||||||
rwEnabled bool,
|
rwEnabled bool,
|
||||||
otlpEnabled bool,
|
otlpEnabled bool,
|
||||||
remoteWriteReducedProto bool,
|
enableRemoteWrite11 bool,
|
||||||
) *API {
|
) *API {
|
||||||
a := &API{
|
a := &API{
|
||||||
QueryEngine: qe,
|
QueryEngine: qe,
|
||||||
|
@ -296,7 +296,7 @@ func NewAPI(
|
||||||
}
|
}
|
||||||
|
|
||||||
if rwEnabled {
|
if rwEnabled {
|
||||||
a.remoteWriteHandler = remote.NewWriteHandler(logger, registerer, ap, remoteWriteReducedProto)
|
a.remoteWriteHandler = remote.NewWriteHandler(logger, registerer, ap, enableRemoteWrite11)
|
||||||
}
|
}
|
||||||
if otlpEnabled {
|
if otlpEnabled {
|
||||||
a.otlpWriteHandler = remote.NewOTLPWriteHandler(logger, ap)
|
a.otlpWriteHandler = remote.NewOTLPWriteHandler(logger, ap)
|
||||||
|
|
Loading…
Reference in a new issue