-
Notifications
You must be signed in to change notification settings - Fork 175
/
loader.go
37 lines (30 loc) · 902 Bytes
/
loader.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
package metrics
import (
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/client_golang/prometheus/promauto"
)
type LoaderCollector struct {
transactionsSent prometheus.Counter
tpsConfigured prometheus.Gauge
}
func NewLoaderCollector() *LoaderCollector {
cc := &LoaderCollector{
transactionsSent: promauto.NewCounter(prometheus.CounterOpts{
Name: "transactions_sent",
Namespace: namespaceLoader,
Help: "transactions sent by the loader",
}),
tpsConfigured: promauto.NewGauge(prometheus.GaugeOpts{
Name: "transactions_per_second_configured",
Namespace: namespaceLoader,
Help: "transactions per second that the loader should send",
}),
}
return cc
}
func (cc *LoaderCollector) TransactionSent() {
cc.transactionsSent.Inc()
}
func (cc *LoaderCollector) SetTPSConfigured(tps int) {
cc.tpsConfigured.Set(float64(tps))
}