mirror of
https://github.com/tailscale/tailscale.git
synced 2024-11-29 04:55:31 +00:00
tsweb/varz: fix exporting histograms
Updates tailscale/corp#8641 Signed-off-by: Maisem Ali <maisem@tailscale.com>
This commit is contained in:
parent
1bd3edbb46
commit
5ee349e075
@ -34,10 +34,11 @@ func init() {
|
|||||||
gaugePrefix = "gauge_"
|
gaugePrefix = "gauge_"
|
||||||
counterPrefix = "counter_"
|
counterPrefix = "counter_"
|
||||||
labelMapPrefix = "labelmap_"
|
labelMapPrefix = "labelmap_"
|
||||||
|
histogramPrefix = "histogram_"
|
||||||
)
|
)
|
||||||
|
|
||||||
// prefixesToTrim contains key prefixes to remove when exporting and sorting metrics.
|
// prefixesToTrim contains key prefixes to remove when exporting and sorting metrics.
|
||||||
var prefixesToTrim = []string{gaugePrefix, counterPrefix, labelMapPrefix}
|
var prefixesToTrim = []string{gaugePrefix, counterPrefix, labelMapPrefix, histogramPrefix}
|
||||||
|
|
||||||
var timeStart = time.Now()
|
var timeStart = time.Now()
|
||||||
|
|
||||||
@ -71,10 +72,12 @@ func prometheusMetric(prefix string, key string) (string, string, string) {
|
|||||||
case strings.HasPrefix(key, gaugePrefix):
|
case strings.HasPrefix(key, gaugePrefix):
|
||||||
typ = "gauge"
|
typ = "gauge"
|
||||||
key = strings.TrimPrefix(key, gaugePrefix)
|
key = strings.TrimPrefix(key, gaugePrefix)
|
||||||
|
|
||||||
case strings.HasPrefix(key, counterPrefix):
|
case strings.HasPrefix(key, counterPrefix):
|
||||||
typ = "counter"
|
typ = "counter"
|
||||||
key = strings.TrimPrefix(key, counterPrefix)
|
key = strings.TrimPrefix(key, counterPrefix)
|
||||||
|
case strings.HasPrefix(key, histogramPrefix):
|
||||||
|
typ = "histogram"
|
||||||
|
key = strings.TrimPrefix(key, histogramPrefix)
|
||||||
}
|
}
|
||||||
if strings.HasPrefix(key, labelMapPrefix) {
|
if strings.HasPrefix(key, labelMapPrefix) {
|
||||||
key = strings.TrimPrefix(key, labelMapPrefix)
|
key = strings.TrimPrefix(key, labelMapPrefix)
|
||||||
|
Loading…
Reference in New Issue
Block a user