-
Notifications
You must be signed in to change notification settings - Fork 3
/
metrics.go
37 lines (33 loc) · 1.28 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
package dkafka
import (
"net/http"
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/client_golang/prometheus/promauto"
"github.com/prometheus/client_golang/prometheus/promhttp"
"go.uber.org/zap"
)
var (
messagesSent = promauto.NewCounter(prometheus.CounterOpts{
Name: "dkafka_sent_messages",
Help: "The total number of sent messages",
})
transactionTracesReceived = promauto.NewCounter(prometheus.CounterOpts{
Name: "dkafka_received_transaction_traces",
Help: "The total number of transaction traces received from firehose",
})
actionTracesReceived = promauto.NewCounter(prometheus.CounterOpts{
Name: "dkafka_received_action_traces",
Help: "The total number of action traces received from firehose",
})
blocksReceived = promauto.NewCounter(prometheus.CounterOpts{
Name: "dkafka_received_blocks",
Help: "The total number of blocks receivedfrom firehose",
})
)
func startPrometheusMetrics(path string, listenAddr string) {
zlog.Info("Starting prometheus HTTP server", zap.String("listen_addr", listenAddr), zap.String("path", path))
http.Handle(path, promhttp.Handler())
if err := http.ListenAndServe(listenAddr, nil); err != nil {
zlog.Warn("prometheus server failed", zap.String("listen_addr", listenAddr), zap.String("path", path), zap.Error(err))
}
}