Add metrics, request logs, and graceful shutdown
ci / test (pull_request) Successful in 9s

This commit is contained in:
2026-07-21 18:03:43 +00:00
parent 4d30598e6b
commit efb0cb0447
8 changed files with 230 additions and 10 deletions
+8
View File
@@ -25,6 +25,8 @@ Tiny API that clones a Git repo and counts its non-empty lines of code.
- Returns both snapshots and their total/per-language LOC delta.
- `GET /health`
- Health plus queue/cache stats.
- `GET /metrics`
- Prometheus-compatible request, cache, scan, file, and line counters. Protected by the API key when one is configured.
## Auth
@@ -70,6 +72,12 @@ curl "http://localhost:3000/ssh/public-key?ssh_key=loc_via_git_ed25519"
- The service also sweeps stale temp directories in case a process dies mid-scan.
- Cache entries live in memory only and expire after `CACHE_TTL_MINUTES`.
## Operations
- Requests emit structured JSON logs with an opaque request ID, route, status, and duration. Query strings and API keys are never logged.
- The service handles `SIGINT` and `SIGTERM`: it stops accepting new connections, clears its cleanup timer, and exits after active connections drain (or 10 seconds).
- `/metrics` is compatible with Prometheus scraping. `/health` remains unauthenticated for container health checks.
## Counting rules
- Only text files are counted.