Add metric for RTT of WebSocket ping messages.

This commit is contained in:
Joachim Bauch 2025-11-06 16:35:54 +01:00
commit 71fda2f258
No known key found for this signature in database
GPG key ID: 77C1D22D53E15F02
3 changed files with 10 additions and 0 deletions

View file

@ -353,6 +353,7 @@ func (c *Client) ReadPump() {
log.Printf("Client from %s has RTT of %d ms (%s)", addr, rtt_ms, rtt)
}
}
statsClientRTT.Observe(float64(rtt.Milliseconds()))
c.getHandler().OnRTTReceived(c, rtt)
}
return nil

View file

@ -32,9 +32,17 @@ var (
Name: "countries_total",
Help: "The total number of connections by country",
}, []string{"country"})
statsClientRTT = prometheus.NewHistogram(prometheus.HistogramOpts{
Namespace: "signaling",
Subsystem: "client",
Name: "rtt",
Help: "The roundtrip time of WebSocket ping messages in milliseconds",
Buckets: prometheus.ExponentialBucketsRange(1, 30000, 50),
})
clientStats = []prometheus.Collector{
statsClientCountries,
statsClientRTT,
}
)

View file

@ -59,3 +59,4 @@ The following metrics are available:
| `signaling_mcu_backend_usage` | Gauge | 2.0.5 | The current usage of signaling proxy backends in percent | `url`, `direction` |
| `signaling_mcu_backend_bandwidth` | Gauge | 2.0.5 | The current bandwidth of signaling proxy backends in bytes per second | `url`, `direction` |
| `signaling_proxy_load` | Gauge | 2.0.5 | The current load of the signaling proxy | |
| `signaling_client_rtt` | Histogram | 2.0.5 | The roundtrip time of WebSocket ping messages in milliseconds | |