Newer
Older
Angelo Capossele
committed
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
package prometheus
import (
"github.com/iotaledger/goshimmer/plugins/banner"
"github.com/iotaledger/goshimmer/plugins/metrics"
"github.com/prometheus/client_golang/prometheus"
)
var (
infoApp *prometheus.GaugeVec
sync prometheus.Gauge
)
func registerInfoMetrics() {
infoApp = prometheus.NewGaugeVec(
prometheus.GaugeOpts{
Name: "iota_info_app",
Help: "Node software name and version.",
},
[]string{"name", "version"},
)
infoApp.WithLabelValues(banner.AppName, banner.AppVersion).Set(1)
sync = prometheus.NewGauge(prometheus.GaugeOpts{
Name: "sync",
Help: "Node sync status.",
})
registry.MustRegister(infoApp)
registry.MustRegister(sync)
addCollect(collectInfoMetrics)
}
func collectInfoMetrics() {
sync.Set(func() float64 {
if metrics.Synced() {
return 1.0
}
return 0.
}())
}