mirror of
https://github.com/weaveworks/scope.git
synced 2026-07-28 01:31:17 +00:00
Move Counters into Latest
The only place Counters are used is in rendering, for the number of nodes under a topology, so the overhead of holding a unique data structure in every Node is unwarranted. Counters are not set in the probe, so we don't need any backwards-compatibility in report decoding. Similarly they are not set until after all nodes are merged, so we don't need that logic.
This commit is contained in:
@@ -1,6 +1,9 @@
|
||||
package utils
|
||||
|
||||
import (
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/weaveworks/scope/report"
|
||||
)
|
||||
|
||||
@@ -27,6 +30,11 @@ func PruneNode(node report.Node) report.Node {
|
||||
WithTopology(node.Topology).
|
||||
WithAdjacent(node.Adjacency...).
|
||||
WithChildren(prunedChildren)
|
||||
prunedNode.Counters = node.Counters
|
||||
// Copy counters across, but with zero timestamp so they compare equal
|
||||
node.Latest.ForEach(func(k string, _ time.Time, v string) {
|
||||
if strings.HasPrefix(k, report.CounterPrefix) {
|
||||
prunedNode.Latest = prunedNode.Latest.Set(k, time.Time{}, v)
|
||||
}
|
||||
})
|
||||
return prunedNode
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user