Skip to content

Commit

Permalink
chore: added check if flag enabled where missing
Browse files Browse the repository at this point in the history
  • Loading branch information
jmichalek132 committed Oct 31, 2024
1 parent 6be771d commit cc1599c
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions exporter/prometheusremotewriteexporter/exporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit cc1599c

Please sign in to comment.