feat: add coderd_api_websocket_probes_total metric (#25012)

Relates to CODAGT-115

Adds metric `coderd_api_websocket_probes_total`. Every successful
heartbeat for a given path will increment the metric.

Comparing this with `coderd_api_concurrent_websockets` will give an
indication of how many websocket connections are open but in a 'wedged'
state (when heartbeats stopped versus when we closed the connection).
This commit is contained in:
Cian Johnston
2026-06-03 10:46:07 +01:00
committed by GitHub
parent 7703e7a26e
commit 8b058dc949
22 changed files with 596 additions and 171 deletions
+6 -1
View File
@@ -914,6 +914,9 @@ func New(options *Options) *API {
options.WorkspaceAppsStatsCollectorOptions.Reporter = api.statsReporter
}
wsMetrics := httpmw.NewWSMetrics(options.PrometheusRegistry)
api.wsWatcher = httpapi.NewWSWatcher(options.Clock, wsMetrics.RecordProbe)
api.workspaceAppServer = workspaceapps.NewServer(workspaceapps.ServerOptions{
Logger: workspaceAppsLogger,
@@ -926,6 +929,7 @@ func New(options *Options) *API {
SignedTokenProvider: api.WorkspaceAppsProvider,
AgentProvider: api.agentProvider,
StatsCollector: workspaceapps.NewStatsCollector(options.WorkspaceAppsStatsCollectorOptions),
WSWatcher: api.wsWatcher,
DisablePathApps: options.DeploymentValues.DisablePathApps.Value(),
CookiesConfig: options.DeploymentValues.HTTPCookies,
@@ -994,7 +998,7 @@ func New(options *Options) *API {
options.PrometheusRegistry.MustRegister(derpmetrics.NewDERPExpvarCollector(options.DERPServer))
}
cors := httpmw.Cors(options.DeploymentValues.Dangerous.AllowAllCors.Value())
prometheusMW := httpmw.Prometheus(options.PrometheusRegistry)
prometheusMW := httpmw.Prometheus(options.PrometheusRegistry, wsMetrics)
r.Use(
sharedhttpmw.Recover(api.Logger),
@@ -2251,6 +2255,7 @@ type API struct {
metadataBatcher *metadatabatcher.Batcher
lifecycleMetrics *agentapi.LifecycleMetrics
workspaceAgentRPCMetrics *WorkspaceAgentRPCMetrics
wsWatcher *httpapi.WSWatcher
Acquirer *provisionerdserver.Acquirer
// dbRolluper rolls up template usage stats from raw agent and app