* add prometheus.gateway flag support * instance: peerid * job: network_type/shard Signed-off-by: Leo Chen <leo@harmony.one>pull/3466/head
parent
3237f43adc
commit
e1c528e9ff
@ -0,0 +1,34 @@ |
||||
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(pubkey string) *push.Pusher { |
||||
onceForPusher.Do(func() { |
||||
if registry == nil { |
||||
registry = prometheus.NewRegistry() |
||||
} |
||||
pusher = push.New("https://gateway.harmony.one", "hmy"). |
||||
Gatherer(registry). |
||||
Grouping("instance", pubkey) |
||||
}) |
||||
return pusher |
||||
} |
||||
|
||||
func PromRegistry() *prometheus.Registry { |
||||
if registry == nil { |
||||
registry = prometheus.NewRegistry() |
||||
} |
||||
return registry |
||||
} |
Loading…
Reference in new issue