Opts struct, no self-registration

This commit is contained in:
Josh Deprez 2024-10-01 14:37:33 +10:00
parent 0e7e16e4b6
commit f75fba266e

View file

@ -17,13 +17,21 @@ type LiteGaugeSummary struct {
desc *prometheus.Desc
}
func NewLiteGaugeSummary(varName, help string) *LiteGaugeSummary {
type LiteGaugeSummaryOpts struct {
// As for usual Prometheus metrics
Namespace, Subsystem, Name, Help string
// As for usual Prometheus metrics
ConstLabels prometheus.Labels
}
func NewLiteGaugeSummary(opts LiteGaugeSummaryOpts) *LiteGaugeSummary {
varName := prometheus.BuildFQName(opts.Namespace, opts.Subsystem, opts.Name)
s := &LiteGaugeSummary{
min: math.Inf(1),
max: math.Inf(-1),
desc: prometheus.NewDesc(varName, help, []string{"stat"}, nil),
desc: prometheus.NewDesc(varName, opts.Help, []string{"stat"}, opts.ConstLabels),
}
prometheus.MustRegister(s)
return s
}