mirror of
https://github.com/netbirdio/gvisor.git
synced 2026-05-22 17:12:49 -07:00
Metrics: Refactor uint64 metric constructor, allow non-cumulative gauges.
This turns the uint64 metric constructor arguments into a struct, making it more explicit as to what each part means. It also allows the creation of non-cumulative uint64 (gauge) metrics, and adds methods to decrement or set them. PiperOrigin-RevId: 647134245
This commit is contained in:
committed by
gVisor bot
parent
89ae593e2a
commit
abde965590
@@ -80,13 +80,21 @@ func statCounterValue(cm *tcpip.StatCounter) func(...*metric.FieldValue) uint64
|
||||
|
||||
func mustCreateMetric(name, description string) *tcpip.StatCounter {
|
||||
var cm tcpip.StatCounter
|
||||
metric.MustRegisterCustomUint64Metric(name, true /* cumulative */, false /* sync */, description, statCounterValue(&cm))
|
||||
metric.MustRegisterCustomUint64Metric(name,
|
||||
metric.Uint64Metadata{
|
||||
Cumulative: true,
|
||||
Description: description,
|
||||
}, statCounterValue(&cm))
|
||||
return &cm
|
||||
}
|
||||
|
||||
func mustCreateGauge(name, description string) *tcpip.StatCounter {
|
||||
var cm tcpip.StatCounter
|
||||
metric.MustRegisterCustomUint64Metric(name, false /* cumulative */, false /* sync */, description, statCounterValue(&cm))
|
||||
metric.MustRegisterCustomUint64Metric(name,
|
||||
metric.Uint64Metadata{
|
||||
Cumulative: false,
|
||||
Description: description,
|
||||
}, statCounterValue(&cm))
|
||||
return &cm
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user