Skip to content

Commit 9022d61

Browse files
committed
fix: expose metrics (#27)
Signed-off-by: Matthias Riegler <[email protected]>
1 parent c353275 commit 9022d61

File tree

3 files changed

+12
-10
lines changed

3 files changed

+12
-10
lines changed

.golangci.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ linters:
2727
- unconvert
2828
- govet
2929
- typecheck
30-
- depguard
3130
- exportloopref
3231
- gofumpt
3332
- goimports
@@ -41,6 +40,7 @@ linters:
4140
- gosec
4241
disable:
4342
- unparam
43+
- depguard
4444

4545
issues:
4646
fix: true

.pre-commit-config.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
repos:
22
- repo: [email protected]:ankorstore/pre-commit.git
3-
rev: e1b70866e5804334d8434d1dde92a558783761ff
3+
rev: f2058e70cf98824f0b62ad2bf71bfced5612ff35
44
hooks:
55
- id: required
66

internal/metrics/metrics.go

+10-8
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ import (
1111
"github.com/prometheus/client_golang/prometheus/promhttp"
1212
)
1313

14+
const metricNamespace = "aks_mq_lease_service"
15+
1416
type Metrics interface {
1517
GetFactory() promauto.Factory
1618
GetHTTPHandler() http.Handler
@@ -79,49 +81,49 @@ func (m *metricsImpl) GetHTTPHandler() http.Handler {
7981
}
8082

8183
func (m *metricsImpl) NewCounter(opts prometheus.CounterOpts) prometheus.Counter {
82-
opts.Namespace = m.appName
84+
opts.Namespace = metricNamespace
8385
opts.ConstLabels = m.mergeLabels(opts.ConstLabels)
8486
return m.GetFactory().NewCounter(opts)
8587
}
8688

8789
func (m *metricsImpl) NewCounterVec(opts prometheus.CounterOpts, labelNames []string) *prometheus.CounterVec {
88-
opts.Namespace = m.appName
90+
opts.Namespace = metricNamespace
8991
opts.ConstLabels = m.mergeLabels(opts.ConstLabels)
9092
return m.GetFactory().NewCounterVec(opts, m.mergeLabelsNames(labelNames))
9193
}
9294

9395
func (m *metricsImpl) NewGauge(opts prometheus.GaugeOpts) prometheus.Gauge {
94-
opts.Namespace = m.appName
96+
opts.Namespace = metricNamespace
9597
opts.ConstLabels = m.mergeLabels(opts.ConstLabels)
9698
return m.GetFactory().NewGauge(opts)
9799
}
98100

99101
func (m *metricsImpl) NewGaugeVec(opts prometheus.GaugeOpts, labelNames []string) *prometheus.GaugeVec {
100-
opts.Namespace = m.appName
102+
opts.Namespace = metricNamespace
101103
opts.ConstLabels = m.mergeLabels(opts.ConstLabels)
102104
return m.GetFactory().NewGaugeVec(opts, m.mergeLabelsNames(labelNames))
103105
}
104106

105107
func (m *metricsImpl) NewSummary(opts prometheus.SummaryOpts) prometheus.Summary {
106-
opts.Namespace = m.appName
108+
opts.Namespace = metricNamespace
107109
opts.ConstLabels = m.mergeLabels(opts.ConstLabels)
108110
return m.GetFactory().NewSummary(opts)
109111
}
110112

111113
func (m *metricsImpl) NewSummaryVec(opts prometheus.SummaryOpts, labelNames []string) *prometheus.SummaryVec {
112-
opts.Namespace = m.appName
114+
opts.Namespace = metricNamespace
113115
opts.ConstLabels = m.mergeLabels(opts.ConstLabels)
114116
return m.GetFactory().NewSummaryVec(opts, m.mergeLabelsNames(labelNames))
115117
}
116118

117119
func (m *metricsImpl) NewHistogram(opts prometheus.HistogramOpts) prometheus.Histogram {
118-
opts.Namespace = m.appName
120+
opts.Namespace = metricNamespace
119121
opts.ConstLabels = m.mergeLabels(opts.ConstLabels)
120122
return m.GetFactory().NewHistogram(opts)
121123
}
122124

123125
func (m *metricsImpl) NewHistogramVec(opts prometheus.HistogramOpts, labelNames []string) *prometheus.HistogramVec {
124-
opts.Namespace = m.appName
126+
opts.Namespace = metricNamespace
125127
opts.ConstLabels = m.mergeLabels(opts.ConstLabels)
126128
return m.GetFactory().NewHistogramVec(opts, m.mergeLabelsNames(labelNames))
127129
}

0 commit comments

Comments
 (0)