1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
|
package metrics
type handlerConfig struct {
labelValues map[string]string
}
// HandlerOption is used to pass options to the HandlerFactory instance.
type HandlerOption func(*handlerConfig)
func applyHandlerOptions(opts []HandlerOption) handlerConfig {
config := handlerConfig{}
for _, v := range opts {
v(&config)
}
return config
}
// WithLabelValues will configure labels values to apply to this handler.
func WithLabelValues(labelValues map[string]string) HandlerOption {
return func(config *handlerConfig) {
config.labelValues = labelValues
}
}
|