-
Notifications
You must be signed in to change notification settings - Fork 2
/
metrics.go
40 lines (33 loc) · 903 Bytes
/
metrics.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
package models
import (
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/client_golang/prometheus/promauto"
)
const (
appKeyLabel = "app_key"
)
var (
hagallSessionCount = promauto.NewGaugeVec(prometheus.GaugeOpts{
Name: "session_count",
Help: "The number of sessions.",
}, []string{appKeyLabel})
hagallSessionCountTotal = promauto.NewCounterVec(prometheus.CounterOpts{
Name: "session_count_total",
Help: "The total number of sessions.",
}, []string{appKeyLabel})
)
func instrumentIncreaseSessionGauge(appKey string) {
hagallSessionCount.
With(prometheus.Labels{appKeyLabel: appKey}).
Inc()
}
func instrumentDecreaseSessionGauge(appKey string) {
hagallSessionCount.
With(prometheus.Labels{appKeyLabel: appKey}).
Dec()
}
func instrumentCountSession(appKey string) {
hagallSessionCountTotal.
With(prometheus.Labels{appKeyLabel: appKey}).
Inc()
}