mirror of
https://github.com/livekit/livekit.git
synced 2026-07-29 09:49:26 +00:00
Use LocalNode ID in Prometheus metrics (#959)
This commit is contained in:
@@ -14,6 +14,7 @@ import (
|
||||
"github.com/urfave/cli/v2"
|
||||
|
||||
serverlogger "github.com/livekit/livekit-server/pkg/logger"
|
||||
"github.com/livekit/livekit-server/pkg/telemetry/prometheus"
|
||||
"github.com/livekit/protocol/logger"
|
||||
|
||||
"github.com/livekit/livekit-server/pkg/config"
|
||||
@@ -216,6 +217,8 @@ func startServer(c *cli.Context) error {
|
||||
return err
|
||||
}
|
||||
|
||||
prometheus.Init(currentNode.Id)
|
||||
|
||||
server, err := service.InitializeServer(conf, currentNode)
|
||||
if err != nil {
|
||||
return err
|
||||
|
||||
@@ -6,8 +6,13 @@ import (
|
||||
|
||||
"github.com/livekit/livekit-server/pkg/rtc/types"
|
||||
"github.com/livekit/livekit-server/pkg/rtc/types/typesfakes"
|
||||
"github.com/livekit/livekit-server/pkg/telemetry/prometheus"
|
||||
)
|
||||
|
||||
func init() {
|
||||
prometheus.Init("test")
|
||||
}
|
||||
|
||||
func newMockParticipant(identity livekit.ParticipantIdentity, protocol types.ProtocolVersion, hidden bool, publisher bool) *typesfakes.FakeLocalParticipant {
|
||||
p := &typesfakes.FakeLocalParticipant{}
|
||||
sid := utils.NewGuid(utils.ParticipantPrefix)
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -9,9 +9,14 @@ import (
|
||||
"github.com/livekit/protocol/livekit"
|
||||
|
||||
"github.com/livekit/livekit-server/pkg/telemetry"
|
||||
"github.com/livekit/livekit-server/pkg/telemetry/prometheus"
|
||||
"github.com/livekit/livekit-server/pkg/telemetry/telemetryfakes"
|
||||
)
|
||||
|
||||
func init() {
|
||||
prometheus.Init("test")
|
||||
}
|
||||
|
||||
type telemetryServiceFixture struct {
|
||||
sut telemetry.TelemetryServiceInternal
|
||||
analytics *telemetryfakes.FakeAnalyticsService
|
||||
|
||||
@@ -20,6 +20,7 @@ import (
|
||||
serverlogger "github.com/livekit/livekit-server/pkg/logger"
|
||||
"github.com/livekit/livekit-server/pkg/routing"
|
||||
"github.com/livekit/livekit-server/pkg/service"
|
||||
"github.com/livekit/livekit-server/pkg/telemetry/prometheus"
|
||||
"github.com/livekit/livekit-server/pkg/testutils"
|
||||
testclient "github.com/livekit/livekit-server/test/client"
|
||||
)
|
||||
@@ -39,14 +40,14 @@ const (
|
||||
// connectTimeout = 5000 * time.Second
|
||||
)
|
||||
|
||||
var (
|
||||
roomClient livekit.RoomService
|
||||
)
|
||||
var roomClient livekit.RoomService
|
||||
|
||||
func init() {
|
||||
serverlogger.InitFromConfig(config.LoggingConfig{
|
||||
Config: logger.Config{Level: "debug"},
|
||||
})
|
||||
|
||||
prometheus.Init("test")
|
||||
}
|
||||
|
||||
func setupSingleNodeTest(name string) (*service.LivekitServer, func()) {
|
||||
@@ -222,6 +223,7 @@ func createRTCClientWithToken(token string, port int, opts *testclient.Options)
|
||||
|
||||
return c
|
||||
}
|
||||
|
||||
func redisClient() *redis.Client {
|
||||
return redis.NewClient(&redis.Options{
|
||||
Addr: "localhost:6379",
|
||||
|
||||
Reference in New Issue
Block a user