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:
33
README.md
33
README.md
@@ -1399,13 +1399,40 @@ Return server metadata. No authentication required.
|
||||
|
||||
### GET /.well-known/healthcheck.json — Health Check
|
||||
|
||||
Standard health check endpoint. No authentication required.
|
||||
Standard health check endpoint. No authentication required. Returns server
|
||||
health status and runtime statistics.
|
||||
|
||||
**Response:** `200 OK`
|
||||
|
||||
```json
|
||||
{"status": "ok"}
|
||||
{
|
||||
"status": "ok",
|
||||
"now": "2024-01-15T12:00:00.000000000Z",
|
||||
"uptimeSeconds": 3600,
|
||||
"uptimeHuman": "1h0m0s",
|
||||
"version": "0.1.0",
|
||||
"appname": "neoirc",
|
||||
"maintenanceMode": false,
|
||||
"sessions": 42,
|
||||
"clients": 85,
|
||||
"queuedLines": 128,
|
||||
"channels": 7,
|
||||
"connectionsSinceBoot": 200,
|
||||
"sessionsSinceBoot": 150,
|
||||
"messagesSinceBoot": 5000
|
||||
}
|
||||
```
|
||||
|
||||
| Field | Description |
|
||||
| ---------------------- | ------------------------------------------------- |
|
||||
| `sessions` | Current number of active sessions |
|
||||
| `clients` | Current number of connected clients |
|
||||
| `queuedLines` | Total entries in client output queues |
|
||||
| `channels` | Current number of channels |
|
||||
| `connectionsSinceBoot` | Total client connections since server start |
|
||||
| `sessionsSinceBoot` | Total sessions created since server start |
|
||||
| `messagesSinceBoot` | Total PRIVMSG/NOTICE messages sent since server start |
|
||||
|
||||
---
|
||||
|
||||
## Message Flow
|
||||
@@ -2332,6 +2359,8 @@ neoirc/
|
||||
│ │ └── healthcheck.go # Health check handler
|
||||
│ ├── healthcheck/ # Health check logic
|
||||
│ │ └── healthcheck.go
|
||||
│ ├── stats/ # Runtime statistics (atomic counters)
|
||||
│ │ └── stats.go
|
||||
│ ├── logger/ # slog-based logging
|
||||
│ │ └── logger.go
|
||||
│ ├── middleware/ # HTTP middleware (logging, CORS, metrics, auth)
|
||||
|
||||
Reference in New Issue
Block a user