qos: Do not export zero metrics counters #1690
1 changed files with 19 additions and 6 deletions
|
@ -211,13 +211,26 @@ func (n *mClockLimiter) startMetricsCollect() {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
metrics := n.metrics.Load().metrics
|
metrics := n.metrics.Load().metrics
|
||||||
for tag, s := range n.readStats {
|
exportMetrics(metrics, n.readStats, shardID, "read")
|
||||||
metrics.SetOperationTagCounters(shardID, "read", tag, s.pending.Load(), s.inProgress.Load(), s.completed.Load(), s.resourceExhausted.Load())
|
exportMetrics(metrics, n.writeStats, shardID, "write")
|
||||||
}
|
|
||||||
for tag, s := range n.writeStats {
|
|
||||||
metrics.SetOperationTagCounters(shardID, "write", tag, s.pending.Load(), s.inProgress.Load(), s.completed.Load(), s.resourceExhausted.Load())
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func exportMetrics(metrics Metrics, stats map[string]*stat, shardID, operation string) {
|
||||||
|
var pending uint64
|
||||||
|
var inProgress uint64
|
||||||
|
var completed uint64
|
||||||
|
var resExh uint64
|
||||||
|
for tag, s := range stats {
|
||||||
|
pending = s.pending.Load()
|
||||||
|
inProgress = s.inProgress.Load()
|
||||||
|
completed = s.completed.Load()
|
||||||
|
resExh = s.resourceExhausted.Load()
|
||||||
|
if pending == 0 && inProgress == 0 && completed == 0 && resExh == 0 {
|
||||||
|
|||||||
|
continue
|
||||||
|
}
|
||||||
|
metrics.SetOperationTagCounters(shardID, operation, tag, pending, inProgress, completed, resExh)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue
These counters only increase, so we don't need to consider case of removing metric on
1 -> 0
transition, right?right