// eachRecordableValue visits each metric in the registry, calling the supplied // function once for each recordable value represented by that metric. This is // useful to expand certain metric types (such as histograms) into multiple // recordable values. func eachRecordableValue(reg *metric.Registry, fn func(string, float64)) { reg.Each(func(name string, mtr interface{}) { if histogram, ok := mtr.(*metric.Histogram); ok { curr := histogram.Current() for _, pt := range recordHistogramQuantiles { fn(name+pt.suffix, float64(curr.ValueAtQuantile(pt.quantile))) } } else { val, err := extractValue(mtr) if err != nil { log.Warning(context.TODO(), err) return } fn(name, val) } }) }