Skip to content

Commit

Permalink
Remove unnecessary if statements
Browse files Browse the repository at this point in the history
Signed-off-by: Marco Pracucci <[email protected]>
  • Loading branch information
pracucci committed Jan 28, 2025
1 parent ace9340 commit 74ade43
Showing 1 changed file with 4 additions and 12 deletions.
16 changes: 4 additions & 12 deletions tsdb/postings_for_matchers_cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -351,18 +351,10 @@ func (c *PostingsForMatchersCache) expire() {
}

// Keep track of the reason why items where evicted.
if evictionReasons[evictionReasonTTL] > 0 {
c.metrics.evictionsBecauseTTL.Add(float64(evictionReasons[evictionReasonTTL]))
}
if evictionReasons[evictionReasonMaxBytes] > 0 {
c.metrics.evictionsBecauseMaxBytes.Add(float64(evictionReasons[evictionReasonMaxBytes]))
}
if evictionReasons[evictionReasonMaxItems] > 0 {
c.metrics.evictionsBecauseMaxItems.Add(float64(evictionReasons[evictionReasonMaxItems]))
}
if evictionReasons[evictionReasonUnknown] > 0 {
c.metrics.evictionsBecauseUnknown.Add(float64(evictionReasons[evictionReasonUnknown]))
}
c.metrics.evictionsBecauseTTL.Add(float64(evictionReasons[evictionReasonTTL]))
c.metrics.evictionsBecauseMaxBytes.Add(float64(evictionReasons[evictionReasonMaxBytes]))
c.metrics.evictionsBecauseMaxItems.Add(float64(evictionReasons[evictionReasonMaxItems]))
c.metrics.evictionsBecauseUnknown.Add(float64(evictionReasons[evictionReasonUnknown]))
}

// shouldEvictHead returns true if cache head should be evicted, either because it's too old,
Expand Down

0 comments on commit 74ade43

Please sign in to comment.