MCPcopy
hub / github.com/livekit/livekit / Init

Function Init

pkg/telemetry/prometheus/node.go:50–135  ·  view source on GitHub ↗
(nodeID string, nodeType livekit.NodeType)

Source from the content-addressed store, hash-verified

48)
49
50func Init(nodeID string, nodeType livekit.NodeType) error {
51 if initialized.Swap(true) {
52 return nil
53 }
54
55 promMessageCounter = prometheus.NewCounterVec(
56 prometheus.CounterOpts{
57 Namespace: livekitNamespace,
58 Subsystem: "node",
59 Name: "messages",
60 ConstLabels: prometheus.Labels{"node_id": nodeID, "node_type": nodeType.String()},
61 },
62 []string{"type", "status", "direction"},
63 )
64
65 promServiceOperationCounter = prometheus.NewCounterVec(
66 prometheus.CounterOpts{
67 Namespace: livekitNamespace,
68 Subsystem: "node",
69 Name: "service_operation",
70 ConstLabels: prometheus.Labels{"node_id": nodeID, "node_type": nodeType.String()},
71 },
72 []string{"type", "status", "error_type"},
73 )
74
75 promTwirpRequestStatusCounter = prometheus.NewCounterVec(
76 prometheus.CounterOpts{
77 Namespace: livekitNamespace,
78 Subsystem: "node",
79 Name: "twirp_request_status",
80 ConstLabels: prometheus.Labels{"node_id": nodeID, "node_type": nodeType.String()},
81 },
82 []string{"service", "method", "status", "code"},
83 )
84
85 promTwirpRequestLatency = prometheus.NewHistogramVec(
86 prometheus.HistogramOpts{
87 Namespace: livekitNamespace,
88 Subsystem: "node",
89 Name: "twirp_request_latency_ms",
90 ConstLabels: prometheus.Labels{"node_id": nodeID, "node_type": nodeType.String()},
91 Buckets: []float64{5, 10, 25, 50, 100, 250, 500, 1000, 2500, 5000, 10000, 30000, 60000},
92 },
93 []string{"service", "method"},
94 )
95
96 promSysPacketGauge = prometheus.NewGaugeVec(
97 prometheus.GaugeOpts{
98 Namespace: livekitNamespace,
99 Subsystem: "node",
100 Name: "packet_total",
101 ConstLabels: prometheus.Labels{"node_id": nodeID, "node_type": nodeType.String()},
102 Help: "System level packet count. Count starts at 0 when service is first started.",
103 },
104 []string{"type"},
105 )
106
107 prometheus.MustRegister(promMessageCounter)

Callers 5

initFunction · 0.92
initFunction · 0.92
initFunction · 0.92
initFunction · 0.92
startServerFunction · 0.92

Calls 8

initPacketStatsFunction · 0.85
initRoomStatsFunction · 0.85
initQualityStatsFunction · 0.85
initDataPacketStatsFunction · 0.85
initDebugStatsFunction · 0.85
getTCStatsFunction · 0.70
SwapMethod · 0.45
StringMethod · 0.45

Tested by 3

initFunction · 0.74
initFunction · 0.74
initFunction · 0.74