Skip to content

Commit

Permalink
Fix race condition on ingester client metric
Browse files Browse the repository at this point in the history
Signed-off-by: alanprot <[email protected]>
  • Loading branch information
alanprot committed May 9, 2024
1 parent bc4d24c commit ada252a
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions pkg/ingester/client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,9 @@ func (c *closableHealthAndIngesterClient) Push(ctx context.Context, in *cortexpb

func (c *closableHealthAndIngesterClient) handlePushRequest(mainFunc func() (*cortexpb.WriteResponse, error)) (*cortexpb.WriteResponse, error) {
currentInflight := c.inflightRequests.Inc()
c.inflightPushRequests.WithLabelValues(c.addr).Inc()
c.inflightPushRequests.WithLabelValues(c.addr).Set(float64(currentInflight))
defer func() {
c.inflightPushRequests.WithLabelValues(c.addr).Dec()
c.inflightRequests.Dec()
c.inflightPushRequests.WithLabelValues(c.addr).Set(float64(c.inflightRequests.Dec()))
}()
if c.maxInflightPushRequests > 0 && currentInflight > c.maxInflightPushRequests {
return nil, errTooManyInflightPushRequests
Expand Down

0 comments on commit ada252a

Please sign in to comment.