@@ -685,26 +685,28 @@ type remoteWriteParams struct {
685685 alreadyReplicated bool
686686}
687687
688- func (h * Handler ) gatherWriteStats (localWrites map [endpointReplica ]map [string ]trackedSeries ) tenantRequestStats {
688+ func (h * Handler ) gatherWriteStats (writes ... map [endpointReplica ]map [string ]trackedSeries ) tenantRequestStats {
689689 var stats tenantRequestStats = make (tenantRequestStats )
690690
691- for er := range localWrites {
692- for tenant , series := range localWrites [er ] {
693- samples := 0
691+ for _ , write := range writes {
692+ for er := range write {
693+ for tenant , series := range write [er ] {
694+ samples := 0
694695
695- for _ , ts := range series .timeSeries {
696- samples += len (ts .Samples )
697- }
696+ for _ , ts := range series .timeSeries {
697+ samples += len (ts .Samples )
698+ }
698699
699- if st , ok := stats [tenant ]; ok {
700- st .timeseries += len (series .timeSeries )
701- st .totalSamples += samples
700+ if st , ok := stats [tenant ]; ok {
701+ st .timeseries += len (series .timeSeries )
702+ st .totalSamples += samples
702703
703- stats [tenant ] = st
704- } else {
705- stats [tenant ] = requestStats {
706- timeseries : len (series .timeSeries ),
707- totalSamples : samples ,
704+ stats [tenant ] = st
705+ } else {
706+ stats [tenant ] = requestStats {
707+ timeseries : len (series .timeSeries ),
708+ totalSamples : samples ,
709+ }
708710 }
709711 }
710712 }
@@ -740,7 +742,7 @@ func (h *Handler) fanoutForward(ctx context.Context, params remoteWriteParams) (
740742 return stats , err
741743 }
742744
743- stats = h .gatherWriteStats (localWrites )
745+ stats = h .gatherWriteStats (localWrites , remoteWrites )
744746
745747 // Prepare a buffered channel to receive the responses from the local and remote writes. Remote writes will all go
746748 // asynchronously and with this capacity we will never block on writing to the channel.
0 commit comments