Use LocalNode ID in Prometheus metrics (#959)

This commit is contained in:
Mathew Kamkar
2022-08-25 22:16:20 -07:00
committed by GitHub
parent c64e0b2271
commit 767d660809
5 changed files with 26 additions and 6 deletions
+8 -3
View File
@@ -5,10 +5,10 @@ import (
"github.com/mackerelio/go-osstat/loadavg"
"github.com/prometheus/client_golang/prometheus"
"go.uber.org/atomic"
"github.com/livekit/livekit-server/pkg/config"
"github.com/livekit/protocol/livekit"
"github.com/livekit/protocol/utils"
)
const (
@@ -16,6 +16,8 @@ const (
)
var (
initialized atomic.Bool
MessageCounter *prometheus.CounterVec
ServiceOperationCounter *prometheus.CounterVec
@@ -25,8 +27,11 @@ var (
promSysDroppedPacketPctGauge prometheus.Gauge
)
func init() {
nodeID, _ := utils.LocalNodeID()
func Init(nodeID string) {
if initialized.Swap(true) {
return
}
MessageCounter = prometheus.NewCounterVec(
prometheus.CounterOpts{
Namespace: livekitNamespace,