Skip to content

Commit a537b0e

Browse files
authored
Merge pull request #154696 from dhartunian/blathers/backport-release-25.4-154563
release-25.4: metric: permit counter resets in update assertion
2 parents 0b19670 + 8a53283 commit a537b0e

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
@@ -825,7 +825,7 @@ func (c *Counter) Inc(v int64) {
825825
// maintained elsewhere.
826826
func (c *Counter) Update(val int64) {
827827
if buildutil.CrdbTestBuild {
828-
if prev := c.count.Load(); val < prev {
828+
if prev := c.count.Load(); val < prev && val != 0 {
829829
panic(fmt.Sprintf("Counters should not decrease, prev: %d, new: %d.", prev, val))
830830
}
831831
}
@@ -1446,7 +1446,7 @@ func (cv *CounterVec) Update(labels map[string]string, v int64) {
14461446
}
14471447

14481448
currentValue := cv.Count(labels)
1449-
if currentValue > v {
1449+
if currentValue > v && v != 0 {
14501450
panic(fmt.Sprintf("Counters should not decrease, prev: %d, new: %d.", currentValue, v))
14511451
}
14521452

0 commit comments

Comments
 (0)