Skip to content

Commit c0ef5ce

Browse files
mmaturtraefiker
authored andcommitted
Fix prometheus metrics
1 parent 7c852fb commit c0ef5ce

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

pkg/metrics/prometheus.go

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -506,11 +506,14 @@ func (h *histogram) With(labelValues ...string) metrics.Histogram {
506506

507507
func (h *histogram) Observe(value float64) {
508508
labels := h.labelNamesValues.ToLabels()
509-
collector := h.hv.With(labels)
510-
collector.Observe(value)
511-
h.collectors <- newCollector(h.name, labels, h.hv, func() {
512-
h.hv.Delete(labels)
513-
})
509+
observer := h.hv.With(labels)
510+
observer.Observe(value)
511+
// Do a type assertion to be sure that prometheus will be able to call the Collect method.
512+
if collector, ok := observer.(stdprometheus.Histogram); ok {
513+
h.collectors <- newCollector(h.name, labels, collector, func() {
514+
h.hv.Delete(labels)
515+
})
516+
}
514517
}
515518

516519
func (h *histogram) Describe(ch chan<- *stdprometheus.Desc) {

0 commit comments

Comments
 (0)