From bd6436605d4bd886cb18cbfba5bb8e75da1264ec Mon Sep 17 00:00:00 2001 From: Bryan Boreham Date: Thu, 9 Dec 2021 14:40:44 +0000 Subject: [PATCH] Review feedback Signed-off-by: Bryan Boreham --- storage/remote/queue_manager.go | 10 ++++------ storage/remote/queue_manager_test.go | 16 ---------------- 2 files changed, 4 insertions(+), 22 deletions(-) diff --git a/storage/remote/queue_manager.go b/storage/remote/queue_manager.go index 361113fc6..49de2c8a3 100644 --- a/storage/remote/queue_manager.go +++ b/storage/remote/queue_manager.go @@ -1011,11 +1011,10 @@ func (s *shards) enqueue(ref chunks.HeadSeriesRef, data sampleOrExemplar) bool { if !appended { return false } - switch data.isSample { - case true: + if data.isSample { s.qm.metrics.pendingSamples.Inc() s.enqueuedSamples.Inc() - case false: + } else { s.qm.metrics.pendingExemplars.Inc() s.enqueuedExemplars.Inc() } @@ -1220,15 +1219,14 @@ func (s *shards) populateTimeSeries(batch []sampleOrExemplar, pendingData []prom // Number of pending samples is limited by the fact that sendSamples (via sendSamplesWithBackoff) // retries endlessly, so once we reach max samples, if we can never send to the endpoint we'll // stop reading from the queue. This makes it safe to reference pendingSamples by index. - switch d.isSample { - case true: + if d.isSample { pendingData[nPending].Labels = labelsToLabelsProto(d.seriesLabels, pendingData[nPending].Labels) pendingData[nPending].Samples = append(pendingData[nPending].Samples, prompb.Sample{ Value: d.value, Timestamp: d.timestamp, }) nPendingSamples++ - case false: + } else { pendingData[nPending].Labels = labelsToLabelsProto(d.seriesLabels, pendingData[nPending].Labels) pendingData[nPending].Exemplars = append(pendingData[nPending].Exemplars, prompb.Exemplar{ Labels: labelsToLabelsProto(d.exemplarLabels, nil), diff --git a/storage/remote/queue_manager_test.go b/storage/remote/queue_manager_test.go index 1f12c39b1..f55c4b472 100644 --- a/storage/remote/queue_manager_test.go +++ b/storage/remote/queue_manager_test.go @@ -578,22 +578,6 @@ func (c *TestWriteClient) waitForExpectedData(tb testing.TB) { } } -func (c *TestWriteClient) expectDataCount(numSamples int) { - if !c.withWaitGroup { - return - } - c.mtx.Lock() - defer c.mtx.Unlock() - c.wg.Add(numSamples) -} - -func (c *TestWriteClient) waitForExpectedDataCount() { - if !c.withWaitGroup { - return - } - c.wg.Wait() -} - func (c *TestWriteClient) Store(_ context.Context, req []byte) error { c.mtx.Lock() defer c.mtx.Unlock()