feat: Prometheus /metrics endpoint — Phase 5 -> 6/8
CI / test (push) Successful in 2m30s

- metrics.v: GET /metrics au format OpenMetrics (gauges + counters)
- server.v: route /metrics, Stats.http_polls counter, increment in poll loop
- metrics_test.v: test du endpoint metrics
- ROADMAP: Phase 5 6/8 (Prometheus done)
This commit is contained in:
2026-08-03 18:03:26 -04:00
parent 4150c56054
commit 83778cfb0d
4 changed files with 113 additions and 12 deletions
+6 -1
View File
@@ -15,9 +15,10 @@ pub struct Stats {
pub mut:
total_notifications int
errors int
http_polls int // v0.5: total HTTP poll checks
by_source map[string]int
start_time time.Time
}
pub struct App {
pub mut:
cfg Config
@@ -190,6 +191,9 @@ pub fn (mut app App) handle(req http.Request) http.Response {
if req.url == '/api/silence' {
return app.silence_status_response()
}
if req.url == '/metrics' {
return app.metrics_response()
}
}
.post {
if req.url.starts_with('/api/silence') {
@@ -409,6 +413,7 @@ fn (mut app App) http_poll_loop() {
}
for src in app.cfg.sources.http_poll {
for check in src.checks {
app.stats.http_polls++
app.run_http_check(check)
}
}