Don't count a per-view counter going down as a restart of named
After a reconfig that changed named's views, the cache and resolver counters (summed over views) went down, which was taken for a restart: every counter then counted its total since named started for one minute. Only a new boot time means a restart now; a counter that goes down counts 0. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
89663e366b
commit
33060f86ce
3 files changed
+24
-15
No files matched your search
+8
-11
@@ -96,23 +96,20 @@ func Flatten(body []byte) (*Snapshot, error) {
|
||||
}
|
||||
|
||||
// Delta returns the change from prev to cur. When named restarted (its
|
||||
// boot time changed or a counter went down), the counters started again
|
||||
// from zero, so the current values are the change.
|
||||
// boot time changed), the counters started again from zero, so the
|
||||
// current values are the change. Without a restart, a counter can still
|
||||
// go down: the per-view ones (cache, upstream times, validation) are
|
||||
// summed over named's views, and a reconfig that adds, removes or
|
||||
// recreates views changes that sum. Such a counter counts 0 for the
|
||||
// minute; it must never make every counter count from zero, which would
|
||||
// add everything since named started (millions of "queries" in a minute).
|
||||
func Delta(prev, cur *Snapshot) map[string]int64 {
|
||||
out := map[string]int64{}
|
||||
restarted := prev.BootTime != cur.BootTime
|
||||
if !restarted {
|
||||
for k, n := range cur.Values {
|
||||
if n < prev.Values[k] {
|
||||
restarted = true
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
for k, n := range cur.Values {
|
||||
d := n
|
||||
if !restarted {
|
||||
d = n - prev.Values[k]
|
||||
d = max(n-prev.Values[k], 0)
|
||||
}
|
||||
if d != 0 || k == "queries" {
|
||||
out[k] = d
|
||||
|
||||
Reference in new issue
Block a user