metrics: add a NewLabelMap helper to create and register label maps
Updates tailscale/corp#31174 Signed-off-by: Anton Tolchanov <anton@tailscale.com>
This commit is contained in:
committed by
Anton Tolchanov
parent
76fb09c6bd
commit
17b0c7bfb3
@@ -43,6 +43,14 @@ type LabelMap struct {
|
||||
shardedIntMu syncs.Mutex
|
||||
}
|
||||
|
||||
// NewLabelMap creates and publishes a new LabelMap metric with the given
|
||||
// metric name and label name.
|
||||
func NewLabelMap(metric, label string) *LabelMap {
|
||||
m := &LabelMap{Label: label}
|
||||
expvar.Publish(metric, m)
|
||||
return m
|
||||
}
|
||||
|
||||
// SetInt64 sets the *Int value stored under the given map key.
|
||||
func (m *LabelMap) SetInt64(key string, v int64) {
|
||||
m.Get(key).Set(v)
|
||||
|
||||
Reference in New Issue
Block a user