-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathmetrics.go
40 lines (35 loc) · 1.04 KB
/
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 teleinfo
import (
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/client_golang/prometheus/promauto"
)
const (
tagErrorType = "error_type"
)
var (
frameReadCounter = promauto.NewCounter(prometheus.CounterOpts{
Name: "teleinfo_frames_read_total",
Help: "The total number of read Teleinfo frames",
})
frameReadErrorCounter = promauto.NewCounterVec(
prometheus.CounterOpts{
Name: "teleinfo_frames_read_errors_total",
Help: "The total number of frame read errors",
},
[]string{tagErrorType},
)
frameDecodedCounter = promauto.NewCounter(prometheus.CounterOpts{
Name: "teleinfo_frames_decoded_total",
Help: "The total number of decoded frames",
})
frameDecodeErrorCounter = promauto.NewCounterVec(
prometheus.CounterOpts{
Name: "teleinfo_frames_decode_errors_total",
Help: "The total number of frame decoding errors",
},
[]string{tagErrorType},
)
)
func incrementErrorCounter(counter *prometheus.CounterVec, errorType string) {
counter.With(prometheus.Labels{tagErrorType: errorType}).Inc()
}