File tree Expand file tree Collapse file tree 1 file changed +19
-0
lines changed Expand file tree Collapse file tree 1 file changed +19
-0
lines changed Original file line number Diff line number Diff line change @@ -234,6 +234,14 @@ func NewHistogramVec(opts prometheus.HistogramOpts, labelNames []string) *promet
234
234
return With (prometheus .DefaultRegisterer ).NewHistogramVec (opts , labelNames )
235
235
}
236
236
237
+ // NewUntypedFunc works like the function of the same name in the prometheus
238
+ // package but it automatically registers the UntypedFunc with the
239
+ // prometheus.DefaultRegisterer. If the registration fails, NewUntypedFunc
240
+ // panics.
241
+ func NewUntypedFunc (opts prometheus.UntypedOpts , function func () float64 ) prometheus.UntypedFunc {
242
+ return With (prometheus .DefaultRegisterer ).NewUntypedFunc (opts , function )
243
+ }
244
+
237
245
// Factory provides factory methods to create Collectors that are automatically
238
246
// registered with a Registerer. Create a Factory with the With function,
239
247
// providing a Registerer to auto-register created Collectors with. The zero
@@ -353,3 +361,14 @@ func (f Factory) NewHistogramVec(opts prometheus.HistogramOpts, labelNames []str
353
361
}
354
362
return h
355
363
}
364
+
365
+ // NewUntypedFunc works like the function of the same name in the prometheus
366
+ // package but it automatically registers the UntypedFunc with the Factory's
367
+ // Registerer.
368
+ func (f Factory ) NewUntypedFunc (opts prometheus.UntypedOpts , function func () float64 ) prometheus.UntypedFunc {
369
+ u := prometheus .NewUntypedFunc (opts , function )
370
+ if f .r != nil {
371
+ f .r .MustRegister (u )
372
+ }
373
+ return u
374
+ }
You can’t perform that action at this time.
0 commit comments