Skip to content

Commit 1e9d95a

Browse files
committed
OTLP: add config flag to enable 'quiet zeros' insertion
We need to ensure all receivers of the data can handle it, before we start sending. Signed-off-by: Bryan Boreham <[email protected]>
1 parent 2cc121b commit 1e9d95a

File tree

3 files changed

+7
-1
lines changed

3 files changed

+7
-1
lines changed

storage/remote/otlptranslator/prometheusremotewrite/helper.go

+5-1
Original file line numberDiff line numberDiff line change
@@ -622,7 +622,11 @@ func (c *PrometheusConverter) handleStartTime(startTs, ts int64, labels []prompb
622622

623623
logger.Debug("adding zero value at start_ts", "type", typ, "labels", labelsStringer(labels), "start_ts", startTs, "sample_ts", ts, "sample_value", val)
624624

625-
c.addSample(&prompb.Sample{Timestamp: startTs, Value: math.Float64frombits(value.QuietZeroNaN)}, labels)
625+
var createdTimeValue float64
626+
if settings.EnableStartTimeQuietZero {
627+
createdTimeValue = math.Float64frombits(value.QuietZeroNaN)
628+
}
629+
c.addSample(&prompb.Sample{Timestamp: startTs, Value: createdTimeValue}, labels)
626630
}
627631

628632
// handleHistogramStartTime similar to the method above but for native histograms..

storage/remote/otlptranslator/prometheusremotewrite/helper_test.go

+1
Original file line numberDiff line numberDiff line change
@@ -478,6 +478,7 @@ func TestPrometheusConverter_AddSummaryDataPoints(t *testing.T) {
478478
Settings{
479479
ExportCreatedMetric: true,
480480
EnableCreatedTimestampZeroIngestion: true,
481+
EnableStartTimeQuietZero: true,
481482
ValidIntervalCreatedTimestampZeroIngestion: tt.overrideValidInterval,
482483
},
483484
metric.Name(),

storage/remote/otlptranslator/prometheusremotewrite/metrics_to_prw.go

+1
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ type Settings struct {
4747

4848
// Mimir specifics.
4949
EnableCreatedTimestampZeroIngestion bool
50+
EnableStartTimeQuietZero bool
5051
ValidIntervalCreatedTimestampZeroIngestion time.Duration
5152
}
5253

0 commit comments

Comments
 (0)