File tree Expand file tree Collapse file tree 1 file changed +8
-5
lines changed Expand file tree Collapse file tree 1 file changed +8
-5
lines changed Original file line number Diff line number Diff line change @@ -506,11 +506,14 @@ func (h *histogram) With(labelValues ...string) metrics.Histogram {
506
506
507
507
func (h * histogram ) Observe (value float64 ) {
508
508
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
+ }
514
517
}
515
518
516
519
func (h * histogram ) Describe (ch chan <- * stdprometheus.Desc ) {
You can’t perform that action at this time.
0 commit comments