adding more labels for byte/packet counters

This commit is contained in:
danm
2023-01-31 15:56:05 -07:00
parent 71eac631a1
commit 25a4f12dd5
3 changed files with 15 additions and 13 deletions
+5 -3
View File
@@ -28,7 +28,7 @@ var (
participantRTCConnected atomic.Uint64
participantRTCInit atomic.Uint64
promPacketLabels = []string{"direction", "transmission"}
promPacketLabels = []string{"direction", "transmission", "region"}
promPacketTotal *prometheus.CounterVec
promPacketBytes *prometheus.CounterVec
promRTCPLabels = []string{"direction"}
@@ -128,10 +128,11 @@ func initPacketStats(nodeID string, nodeType livekit.NodeType) {
prometheus.MustRegister(promConnections)
}
func IncrementPackets(direction Direction, count uint64, retransmit bool) {
func IncrementPackets(direction Direction, count uint64, retransmit bool, region string) {
promPacketTotal.WithLabelValues(
string(direction),
transmissionLabel(retransmit),
region,
).Add(float64(count))
if direction == Incoming {
packetsIn.Add(count)
@@ -143,10 +144,11 @@ func IncrementPackets(direction Direction, count uint64, retransmit bool) {
}
}
func IncrementBytes(direction Direction, count uint64, retransmit bool) {
func IncrementBytes(direction Direction, count uint64, retransmit bool, region string) {
promPacketBytes.WithLabelValues(
string(direction),
transmissionLabel(retransmit),
region,
).Add(float64(count))
if direction == Incoming {
bytesIn.Add(count)
+4 -4
View File
@@ -68,13 +68,13 @@ func (t *telemetryService) TrackStats(key StatsKey, stat *livekit.AnalyticsStat)
}
}
prometheus.IncrementRTCP(direction, nacks, plis, firs)
prometheus.IncrementPackets(direction, uint64(packets), false)
prometheus.IncrementBytes(direction, bytes, false)
prometheus.IncrementPackets(direction, uint64(packets), false, "")
prometheus.IncrementBytes(direction, bytes, false, "")
if retransmitPackets != 0 {
prometheus.IncrementPackets(direction, uint64(retransmitPackets), true)
prometheus.IncrementPackets(direction, uint64(retransmitPackets), true, "")
}
if retransmitBytes != 0 {
prometheus.IncrementBytes(direction, retransmitBytes, true)
prometheus.IncrementBytes(direction, retransmitBytes, true, "")
}
if worker, ok := t.getWorker(key.participantID); ok {
+6 -6
View File
@@ -38,7 +38,7 @@ func NewConn(c net.Conn, direction prometheus.Direction) *Conn {
func (c *Conn) Read(b []byte) (n int, err error) {
n, err = c.Conn.Read(b)
if n > 0 {
prometheus.IncrementBytes(prometheus.Incoming, uint64(n), false)
prometheus.IncrementBytes(prometheus.Incoming, uint64(n), false, "")
}
return
}
@@ -46,7 +46,7 @@ func (c *Conn) Read(b []byte) (n int, err error) {
func (c *Conn) Write(b []byte) (n int, err error) {
n, err = c.Conn.Write(b)
if n > 0 {
prometheus.IncrementBytes(prometheus.Outgoing, uint64(n), false)
prometheus.IncrementBytes(prometheus.Outgoing, uint64(n), false, "")
}
return
}
@@ -69,8 +69,8 @@ func NewPacketConn(c net.PacketConn, direction prometheus.Direction) *PacketConn
func (c *PacketConn) ReadFrom(p []byte) (n int, addr net.Addr, err error) {
n, addr, err = c.PacketConn.ReadFrom(p)
if n > 0 {
prometheus.IncrementBytes(prometheus.Incoming, uint64(n), false)
prometheus.IncrementPackets(prometheus.Incoming, 1, false)
prometheus.IncrementBytes(prometheus.Incoming, uint64(n), false, "")
prometheus.IncrementPackets(prometheus.Incoming, 1, false, "")
}
return
}
@@ -78,8 +78,8 @@ func (c *PacketConn) ReadFrom(p []byte) (n int, addr net.Addr, err error) {
func (c *PacketConn) WriteTo(p []byte, addr net.Addr) (n int, err error) {
n, err = c.PacketConn.WriteTo(p, addr)
if n > 0 {
prometheus.IncrementBytes(prometheus.Outgoing, uint64(n), false)
prometheus.IncrementPackets(prometheus.Outgoing, 1, false)
prometheus.IncrementBytes(prometheus.Outgoing, uint64(n), false, "")
prometheus.IncrementPackets(prometheus.Outgoing, 1, false, "")
}
return
}