util/usermetric: add empty label helper

Signed-off-by: Kristoffer Dalby <[email protected]>
This commit is contained in:
Kristoffer Dalby committed 2024-08-15 18:22:57 +02:00
1 parent 55d29a9c6d
commit fffc6a65b2
1 file changed
+15
+15
View File
@@ -33,6 +33,21 @@ func NewMultiLabelMap[T comparable](name string, promType, helpText string) *met
return m
}
// NewMap creates and register a new
// Map variable with the given name and returns it.
//
// Note that usermetric are not protected against duplicate
// metrics name. It is the caller's responsibility to ensure that
// the name is unique.
func NewMap(name string, promType, helpText string) *metrics.MultiLabelMap[struct{}] {
m := &metrics.MultiLabelMap[struct{}]{
Type: promType,
Help: helpText,
}
vars.Set(name, m)
return m
}
// Handler returns a varz.Handler that serves the userfacing expvar contained
// in this package.
func Handler(w http.ResponseWriter, r *http.Request) {