Skip to content

Commit

Permalink
Pass unit as part of promethious metadata.
Browse files Browse the repository at this point in the history
Signed-off-by: Cody Littley <[email protected]>
  • Loading branch information
cody-littley committed Nov 21, 2024
1 parent 49b11e1 commit 2d6c116
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion common/metrics/count_metric.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ type countMetric struct {
func newCountMetric(name string, label string, description string, vec *prometheus.CounterVec) CountMetric {
var counter prometheus.Counter
if vec != nil {
counter = vec.WithLabelValues(label)
counter = vec.WithLabelValues(label, "count")
}

return &countMetric{
Expand Down
2 changes: 1 addition & 1 deletion common/metrics/gauge_metric.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ func newGaugeMetric(

var gauge prometheus.Gauge
if vec != nil {
gauge = vec.WithLabelValues(label)
gauge = vec.WithLabelValues(label, unit)
}

return &gaugeMetric{
Expand Down
2 changes: 1 addition & 1 deletion common/metrics/latency_metric.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ type latencyMetric struct {
func newLatencyMetric(name string, label string, description string, vec *prometheus.SummaryVec) LatencyMetric {
var observer prometheus.Observer
if vec != nil {
observer = vec.WithLabelValues(label)
observer = vec.WithLabelValues(label, "seconds")
}

return &latencyMetric{
Expand Down
6 changes: 3 additions & 3 deletions common/metrics/metrics_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ func (m *metrics) NewLatencyMetric(
Name: name,
Objectives: objectives,
},
[]string{"label"},
[]string{"label", "unit"},
)
m.summaryVecMap[name] = vec
}
Expand Down Expand Up @@ -256,7 +256,7 @@ func (m *metrics) NewCountMetric(
Namespace: m.config.Namespace,
Name: name,
},
[]string{"label"},
[]string{"label", "unit"},
)
m.counterVecMap[name] = vec
}
Expand Down Expand Up @@ -312,7 +312,7 @@ func (m *metrics) newGaugeMetricUnsafe(
Namespace: m.config.Namespace,
Name: name,
},
[]string{"label"},
[]string{"label", "unit"},
)
m.gaugeVecMap[name] = vec
}
Expand Down
2 changes: 1 addition & 1 deletion common/metrics/test/main.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package test
package main

import (
"fmt"
Expand Down

0 comments on commit 2d6c116

Please sign in to comment.