diff --git a/pkg/receive/handler.go b/pkg/receive/handler.go index 208c01b131..d6c2596f36 100644 --- a/pkg/receive/handler.go +++ b/pkg/receive/handler.go @@ -681,35 +681,32 @@ type remoteWriteParams struct { alreadyReplicated bool } -func (h *Handler) gatherWriteStats(writes ...map[endpointReplica]map[string]trackedSeries) tenantRequestStats { +func (h *Handler) gatherWriteStats(localWrites map[endpointReplica]map[string]trackedSeries) tenantRequestStats { var stats tenantRequestStats = make(tenantRequestStats) - for _, write := range writes { - for er := range write { - for tenant, series := range write[er] { - samples := 0 + for er := range localWrites { + for tenant, series := range localWrites[er] { + samples := 0 - for _, ts := range series.timeSeries { - samples += len(ts.Samples) - } + for _, ts := range series.timeSeries { + samples += len(ts.Samples) + } - if st, ok := stats[tenant]; ok { - st.timeseries += len(series.timeSeries) - st.totalSamples += samples + if st, ok := stats[tenant]; ok { + st.timeseries += len(series.timeSeries) + st.totalSamples += samples - stats[tenant] = st - } else { - stats[tenant] = requestStats{ - timeseries: len(series.timeSeries), - totalSamples: samples, - } + stats[tenant] = st + } else { + stats[tenant] = requestStats{ + timeseries: len(series.timeSeries), + totalSamples: samples, } } } } return stats - } func (h *Handler) fanoutForward(ctx context.Context, params remoteWriteParams) (tenantRequestStats, error) { @@ -739,7 +736,7 @@ func (h *Handler) fanoutForward(ctx context.Context, params remoteWriteParams) ( return stats, err } - stats = h.gatherWriteStats(localWrites, remoteWrites) + stats = h.gatherWriteStats(localWrites) // Prepare a buffered channel to receive the responses from the local and remote writes. Remote writes will all go // asynchronously and with this capacity we will never block on writing to the channel.