From cc1599c34e53b4cafd444943fc3d26540a2362f7 Mon Sep 17 00:00:00 2001 From: Juraj Michalek Date: Thu, 31 Oct 2024 19:02:20 +0100 Subject: [PATCH] chore: added check if flag enabled where missing --- .../prometheusremotewriteexporter/exporter.go | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/exporter/prometheusremotewriteexporter/exporter.go b/exporter/prometheusremotewriteexporter/exporter.go index 260790637048..79491c441b1b 100644 --- a/exporter/prometheusremotewriteexporter/exporter.go +++ b/exporter/prometheusremotewriteexporter/exporter.go @@ -332,13 +332,20 @@ func (prwe *prwExporter) execute(ctx context.Context, data []byte) error { req.Header.Add("Content-Encoding", "snappy") req.Header.Set("User-Agent", prwe.userAgentHeader) - switch prwe.RemoteWriteProtoMsg { - case config.RemoteWriteProtoMsgV1: + // If feature flag not enabled support only RW1 + // TODO remove when feature flag removed + if !prwe.enableSendingRW2 { req.Header.Set("Content-Type", "application/x-protobuf") req.Header.Set("X-Prometheus-Remote-Write-Version", "0.1.0") - case config.RemoteWriteProtoMsgV2: - req.Header.Set("Content-Type", "application/x-protobuf;proto=io.prometheus.write.v2.Request") - req.Header.Set("X-Prometheus-Remote-Write-Version", "2.0.0") + } else { + switch prwe.RemoteWriteProtoMsg { + case config.RemoteWriteProtoMsgV1: + req.Header.Set("Content-Type", "application/x-protobuf") + req.Header.Set("X-Prometheus-Remote-Write-Version", "0.1.0") + case config.RemoteWriteProtoMsgV2: + req.Header.Set("Content-Type", "application/x-protobuf;proto=io.prometheus.write.v2.Request") + req.Header.Set("X-Prometheus-Remote-Write-Version", "2.0.0") + } } resp, err := prwe.client.Do(req)