Fix prometheus metrics

This commit is contained in:
Michael 2019-07-24 12:38:03 +02:00 committed by Traefiker Bot
parent 7c852fbf33
commit c0ef5ce512

View file

@ -506,12 +506,15 @@ func (h *histogram) With(labelValues ...string) metrics.Histogram {
func (h *histogram) Observe(value float64) {
labels := h.labelNamesValues.ToLabels()
collector := h.hv.With(labels)
collector.Observe(value)
h.collectors <- newCollector(h.name, labels, h.hv, func() {
observer := h.hv.With(labels)
observer.Observe(value)
// Do a type assertion to be sure that prometheus will be able to call the Collect method.
if collector, ok := observer.(stdprometheus.Histogram); ok {
h.collectors <- newCollector(h.name, labels, collector, func() {
h.hv.Delete(labels)
})
}
}
func (h *histogram) Describe(ch chan<- *stdprometheus.Desc) {
h.hv.Describe(ch)