Skip to content

Commit

Permalink
just defer
Browse files Browse the repository at this point in the history
  • Loading branch information
ying-jeanne committed Jan 16, 2025
1 parent 72c16ea commit f1da054
Showing 1 changed file with 1 addition and 4 deletions.
5 changes: 1 addition & 4 deletions pkg/costattribution/active_tracker.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,20 +78,18 @@ func (at *ActiveSeriesTracker) Increment(lbls labels.Labels, now time.Time) {
at.fillKeyFromLabels(lbls, buf)

at.observedMtx.RLock()
defer at.observedMtx.RUnlock()
as, ok := at.observed[string(buf.Bytes())]
if ok {
as.Inc()
at.observedMtx.RUnlock()
return
}

if !at.overflowSince.IsZero() {
at.observedMtx.RUnlock()
at.overflowCounter.Inc()
return
}

defer at.observedMtx.RUnlock()
as, ok = at.observed[string(buf.Bytes())]
if ok {
as.Inc()
Expand All @@ -110,7 +108,6 @@ func (at *ActiveSeriesTracker) Increment(lbls labels.Labels, now time.Time) {
}

at.observed[string(buf.Bytes())] = atomic.NewInt64(1)

}

func (at *ActiveSeriesTracker) Decrement(lbls labels.Labels) {
Expand Down

0 comments on commit f1da054

Please sign in to comment.