mirror of
https://github.com/coder/coder.git
synced 2026-09-24 15:04:27 +08:00
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:
@@ -68,6 +68,7 @@ type API struct {
|
||||
watcher watcher.Watcher
|
||||
fs afero.Fs
|
||||
execer agentexec.Execer
|
||||
wsWatcher *httpapi.WSWatcher
|
||||
commandEnv CommandEnv
|
||||
ccli ContainerCLI
|
||||
containerLabelIncludeFilter map[string]string // Labels to filter containers by.
|
||||
@@ -348,6 +349,8 @@ func NewAPI(logger slog.Logger, options ...Option) *API {
|
||||
for _, opt := range options {
|
||||
opt(api)
|
||||
}
|
||||
|
||||
api.wsWatcher = httpapi.NewWSWatcher(quartz.NewReal(), nil)
|
||||
if api.commandEnv != nil {
|
||||
api.execer = newCommandEnvExecer(
|
||||
api.logger,
|
||||
@@ -782,7 +785,7 @@ func (api *API) watchContainers(rw http.ResponseWriter, r *http.Request) {
|
||||
ctx, wsNetConn := codersdk.WebsocketNetConn(ctx, conn, websocket.MessageText)
|
||||
defer wsNetConn.Close()
|
||||
|
||||
go httpapi.HeartbeatClose(ctx, api.logger, cancel, conn)
|
||||
ctx = api.wsWatcher.Watch(ctx, api.logger, conn)
|
||||
|
||||
updateCh := make(chan struct{}, 1)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user