/
pgPreparedTransactions_gen.go
51 lines (42 loc) · 1.36 KB
/
pgPreparedTransactions_gen.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
41
42
43
44
45
46
47
48
49
50
51
/*generated by binding gen*/
package models
import (
"github.com/prometheus/client_golang/prometheus"
)
type PgPreparedTransactionsSlice []PgPreparedTransactions
func (r PgPreparedTransactionsSlice) ToMetrics(namespace string, subsystem string, ch chan<- prometheus.Metric, labelsKV ...string) error {
for _, row := range []PgPreparedTransactions(r) {
if err := row.ToMetrics(namespace, subsystem, ch, labelsKV...); err != nil {
return err
}
}
return nil
}
func (r *PgPreparedTransactions) ToMetrics(namespace string, subsystem string, ch chan<- prometheus.Metric, labelsKV ...string) error {
labels := newLabels(labelsKV...)
// labels
labels["database"] = r.Database
// optional labels
// metrics
// oldest (CounterValue)
var oldest float64
if r.Oldest.IsZero() {
oldest = float64(0)
} else {
oldest = float64(r.Oldest.Unix())
}
ch <- prometheus.MustNewConstMetric(
prometheus.NewDesc(
prometheus.BuildFQName(namespace, subsystem, `oldest`), `Time at which the oldest transaction was prepared for commit`, nil, labels,
), prometheus.CounterValue, oldest,
)
// count (GaugeValue)
count := float64(r.Count)
ch <- prometheus.MustNewConstMetric(
prometheus.NewDesc(
prometheus.BuildFQName(namespace, subsystem, `count`), `Number of prepared transactions`, nil, labels,
), prometheus.GaugeValue, count,
)
// optional metrics
return nil
}