-
Notifications
You must be signed in to change notification settings - Fork 216
/
Copy pathcursors.go
35 lines (30 loc) · 1.06 KB
/
cursors.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
package collector
import (
"github.com/prometheus/client_golang/prometheus"
)
var (
cursorsGauge = prometheus.NewGaugeVec(prometheus.GaugeOpts{
Namespace: Namespace,
Name: "cursors",
Help: "The cursors data structure contains data regarding cursor state and use",
}, []string{"state"})
)
// Cursors are the cursor metrics
type Cursors struct {
TotalOpen float64 `bson:"totalOpen"`
TimeOut float64 `bson:"timedOut"`
TotalNoTimeout float64 `bson:"totalNoTimeout"`
Pinned float64 `bson:"pinned"`
}
// Export exports the data to prometheus.
func (cursors *Cursors) Export(ch chan<- prometheus.Metric) {
cursorsGauge.WithLabelValues("total_open").Set(cursors.TotalOpen)
cursorsGauge.WithLabelValues("timed_out").Set(cursors.TimeOut)
cursorsGauge.WithLabelValues("total_no_timeout").Set(cursors.TotalNoTimeout)
cursorsGauge.WithLabelValues("pinned").Set(cursors.Pinned)
cursorsGauge.Collect(ch)
}
// Describe describes the metrics for prometheus
func (cursors *Cursors) Describe(ch chan<- *prometheus.Desc) {
cursorsGauge.Describe(ch)
}