- 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:
@@ -0,0 +1,28 @@
|
||||
module main
|
||||
|
||||
fn test_metrics_keys() {
|
||||
mut app := App{
|
||||
logger: new_logger(.info, false)
|
||||
cfg: Config{
|
||||
filters: FilterConfig{}
|
||||
outgoing: OutgoingConfig{}
|
||||
state: StateConfig{}
|
||||
}
|
||||
poll_state: map[string]bool{}
|
||||
}
|
||||
app.poll_state['http://example.com'] = true
|
||||
app.poll_state['http://down.com'] = false
|
||||
app.stats.total_notifications = 42
|
||||
app.stats.errors = 3
|
||||
app.stats.by_source['docker'] = 10
|
||||
|
||||
resp := app.metrics_response()
|
||||
body := resp.body
|
||||
|
||||
assert body.contains('ntfy_bridge_uptime_seconds')
|
||||
assert body.contains('ntfy_bridge_notifications_total 42')
|
||||
assert body.contains('ntfy_bridge_errors_total 3')
|
||||
assert body.contains('ntfy_bridge_silence_active')
|
||||
assert body.contains('ntfy_bridge_http_polls_total')
|
||||
assert body.contains('# EOF')
|
||||
}
|
||||
Reference in New Issue
Block a user