The core protocol of WoopChain
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
woop/internal/utils/prometheus.go

34 lines
726 B

package utils
import (
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/client_golang/prometheus/push"
"sync"
)
var (
// Prometheus Pusher
onceForPusher sync.Once
pusher *push.Pusher
registry *prometheus.Registry
)
// Pusher returns the pusher, initialized once only
func PromPusher(job string, instance string) *push.Pusher {
onceForPusher.Do(func() {
if registry == nil {
registry = prometheus.NewRegistry()
}
pusher = push.New("https://gateway.harmony.one", job).
Gatherer(registry).
Grouping("instance", instance)
})
return pusher
}
func PromRegistry() *prometheus.Registry {
if registry == nil {
registry = prometheus.NewRegistry()
}
return registry
}