Skip to content

Commit 08e0fd4

Browse files
authored
Merge pull request #154694 from dhartunian/blathers/backport-release-25.3-154563
release-25.3: metric: permit counter resets in update assertion
2 parents ee80eab + 1005d6d commit 08e0fd4

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

pkg/util/metric/metric.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -814,7 +814,7 @@ func (c *Counter) Inc(v int64) {
814814
// maintained elsewhere.
815815
func (c *Counter) Update(val int64) {
816816
if buildutil.CrdbTestBuild {
817-
if prev := c.count.Load(); val < prev {
817+
if prev := c.count.Load(); val < prev && val != 0 {
818818
panic(fmt.Sprintf("Counters should not decrease, prev: %d, new: %d.", prev, val))
819819
}
820820
}
@@ -1435,7 +1435,7 @@ func (cv *CounterVec) Update(labels map[string]string, v int64) {
14351435
}
14361436

14371437
currentValue := cv.Count(labels)
1438-
if currentValue > v {
1438+
if currentValue > v && v != 0 {
14391439
panic(fmt.Sprintf("Counters should not decrease, prev: %d, new: %d.", currentValue, v))
14401440
}
14411441

0 commit comments

Comments
 (0)