feat: add runtime statistics to healthcheck endpoint
All checks were successful
check / check (push) Successful in 1m4s
All checks were successful
check / check (push) Successful in 1m4s
Add the following counters to the healthcheck JSON response: - sessions: current active session count (from DB) - clients: current connected client count (from DB) - queuedLines: total entries in client output queues (from DB) - channels: current channel count (from DB) - connectionsSinceBoot: total client connections since server start - sessionsSinceBoot: total sessions created since server start - messagesSinceBoot: total PRIVMSG/NOTICE messages since server start Implementation: - New internal/stats package with atomic counters for boot-scoped metrics - New DB queries GetClientCount and GetQueueEntryCount - Healthcheck.Healthcheck() now accepts context for DB queries - Counter increments in session creation, registration, login, and messaging - Stats tracker wired via Uber fx dependency injection - Unit tests for stats package (100% coverage) and integration tests - README updated with full healthcheck response documentation closes #74
This commit is contained in:
@@ -82,6 +82,9 @@ func (hdlr *Handlers) handleRegister(
|
||||
return
|
||||
}
|
||||
|
||||
hdlr.stats.IncrSessions()
|
||||
hdlr.stats.IncrConnections()
|
||||
|
||||
hdlr.deliverMOTD(request, clientID, sessionID, payload.Nick)
|
||||
|
||||
hdlr.respondJSON(writer, request, map[string]any{
|
||||
@@ -180,6 +183,8 @@ func (hdlr *Handlers) handleLogin(
|
||||
return
|
||||
}
|
||||
|
||||
hdlr.stats.IncrConnections()
|
||||
|
||||
hdlr.deliverMOTD(
|
||||
request, clientID, sessionID, payload.Nick,
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user