diff --git a/internal/component/prometheus/echo/echo.go b/internal/component/prometheus/echo/echo.go index 918272562d3..c94727af36c 100644 --- a/internal/component/prometheus/echo/echo.go +++ b/internal/component/prometheus/echo/echo.go @@ -146,10 +146,8 @@ func (a *echoAppender) Append(ref storage.SeriesRef, l labels.Labels, t int64, v PrintTimestamp: t > 0, } - if ref == 0 { - ref = storage.SeriesRef(len(a.samples)) - } - return ref, nil + // Zero indicates echo does not care about SeriesRefs + return 0, nil } func (a *echoAppender) AppendExemplar(ref storage.SeriesRef, l labels.Labels, e exemplar.Exemplar) (storage.SeriesRef, error) { @@ -162,10 +160,8 @@ func (a *echoAppender) AppendExemplar(ref storage.SeriesRef, l labels.Labels, e Exemplar: e, } - if ref == 0 { - ref = storage.SeriesRef(1) - } - return ref, nil + // Zero indicates echo does not care about SeriesRefs + return 0, nil } func (a *echoAppender) AppendHistogram(ref storage.SeriesRef, l labels.Labels, t int64, h *histogram.Histogram, fh *histogram.FloatHistogram) (storage.SeriesRef, error) { @@ -180,10 +176,8 @@ func (a *echoAppender) AppendHistogram(ref storage.SeriesRef, l labels.Labels, t } } - if ref == 0 { - ref = storage.SeriesRef(len(a.histograms)) - } - return ref, nil + // Zero indicates echo does not care about SeriesRefs + return 0, nil } func (a *echoAppender) UpdateMetadata(ref storage.SeriesRef, l labels.Labels, m metadata.Metadata) (storage.SeriesRef, error) { @@ -195,10 +189,8 @@ func (a *echoAppender) UpdateMetadata(ref storage.SeriesRef, l labels.Labels, m a.metadata[metricName] = m } - if ref == 0 { - ref = storage.SeriesRef(1) - } - return ref, nil + // Zero indicates echo does not care about SeriesRefs + return 0, nil } func (a *echoAppender) AppendSTZeroSample(ref storage.SeriesRef, l labels.Labels, t, st int64) (storage.SeriesRef, error) { @@ -213,10 +205,8 @@ func (a *echoAppender) AppendSTZeroSample(ref storage.SeriesRef, l labels.Labels PrintTimestamp: t > 0, } - if ref == 0 { - ref = storage.SeriesRef(len(a.samples)) - } - return ref, nil + // Zero indicates echo does not care about SeriesRefs + return 0, nil } func (a *echoAppender) AppendHistogramSTZeroSample(ref storage.SeriesRef, l labels.Labels, t, st int64, h *histogram.Histogram, fh *histogram.FloatHistogram) (storage.SeriesRef, error) { @@ -231,10 +221,8 @@ func (a *echoAppender) AppendHistogramSTZeroSample(ref storage.SeriesRef, l labe } } - if ref == 0 { - ref = storage.SeriesRef(len(a.histograms)) - } - return ref, nil + // Zero indicates echo does not care about SeriesRefs + return 0, nil } func (a *echoAppender) Commit() error { diff --git a/internal/component/prometheus/echo/echo_test.go b/internal/component/prometheus/echo/echo_test.go index 8e0e883e58a..655e17d70d5 100644 --- a/internal/component/prometheus/echo/echo_test.go +++ b/internal/component/prometheus/echo/echo_test.go @@ -75,7 +75,7 @@ func TestAppender_BasicMetrics(t *testing.T) { ref, err := appender.Append(0, lbls, time.Now().Unix(), 42.0) require.NoError(t, err) - require.NotEqual(t, storage.SeriesRef(0), ref) + require.Equal(t, storage.SeriesRef(0), ref) err = appender.Commit() require.NoError(t, err)