metrics: add LabelMap.GetSetFunc

Updates tailscale/corp#7354

Signed-off-by: Maisem Ali <maisem@tailscale.com>
maisem/m1
Maisem Ali 2023-07-02 11:36:36 -07:00
parent 0c427f23bd
commit eaa0a7f8fd
1 changed files with 8 additions and 0 deletions

View File

@ -45,6 +45,14 @@ func (m *LabelMap) Get(key string) *expvar.Int {
return m.Map.Get(key).(*expvar.Int)
}
// GetSetFunc returns a function that sets the expvar.Int named by key.
//
// Most callers should not need this; it exists to satisfy an
// interface elsewhere.
func (m *LabelMap) GetSetFunc(key string) func(delta int64) {
return m.Get(key).Set
}
// GetIncrFunc returns a function that increments the expvar.Int named by key.
//
// Most callers should not need this; it exists to satisfy an