From f253a361eac16060a74a2aa71a22afa98943d1c6 Mon Sep 17 00:00:00 2001 From: hechen-eng Date: Mon, 9 Mar 2026 11:17:30 -0700 Subject: [PATCH] TEL-331: add start ringing metric --- pkg/sip/inbound.go | 1 + pkg/stats/monitor.go | 14 ++++++++++++++ 2 files changed, 15 insertions(+) diff --git a/pkg/sip/inbound.go b/pkg/sip/inbound.go index b4f53ed4..6eee60fd 100644 --- a/pkg/sip/inbound.go +++ b/pkg/sip/inbound.go @@ -679,6 +679,7 @@ func (c *inboundCall) handleInvite(ctx context.Context, tid traceid.ID, req *sip c.call.SipCallId = h.Value() } + c.mon.StartRingingDur().Observe(time.Since(c.callStart).Seconds()) c.cc.StartRinging() // Send initial request. In the best case scenario, we will immediately get a room name to join. // Otherwise, we could even learn that this number is not allowed and reject the call, or ask for pin if required. diff --git a/pkg/stats/monitor.go b/pkg/stats/monitor.go index 6c72c2b0..00d6dd76 100644 --- a/pkg/stats/monitor.go +++ b/pkg/stats/monitor.go @@ -72,6 +72,7 @@ type Monitor struct { durCall *prometheus.HistogramVec durJoin *prometheus.HistogramVec durCheck *prometheus.HistogramVec + durStartRinging *prometheus.HistogramVec cpuLoad prometheus.Gauge sdpSize *prometheus.HistogramVec nodeAvailable prometheus.GaugeFunc @@ -214,6 +215,15 @@ func (m *Monitor) Start(conf *config.Config) error { Buckets: durBucketsOp, }, []string{"dir"})) + m.durStartRinging = mustRegister(m, prometheus.NewHistogramVec(prometheus.HistogramOpts{ + Namespace: "livekit", + Subsystem: "sip", + Name: "dur_start_ringing_sec", + Help: "Duration from INVITE received to 180 Ringing sent", + ConstLabels: prometheus.Labels{"node_id": conf.NodeID}, + Buckets: durBucketsOp, + }, []string{"dir"})) + m.durJoin = mustRegister(m, prometheus.NewHistogramVec(prometheus.HistogramOpts{ Namespace: "livekit", Subsystem: "sip", @@ -428,6 +438,10 @@ func (c *CallMonitor) CheckDur() prometheus.Observer { return c.m.durCheck.With(c.labelsShort(nil)) } +func (c *CallMonitor) StartRingingDur() prometheus.Observer { + return c.m.durStartRinging.With(c.labelsShort(nil)) +} + func (c *CallMonitor) JoinDur() func() time.Duration { return prometheus.NewTimer(c.m.durJoin.With(c.labelsShort(nil))).ObserveDuration }