Files
moloapp/tests/example/prom/metrics_test.cpp
T
retoorandClaude Sonnet 5.5 62fdd08da8 feat(workflow): example covers security, platform, enterprise and resilience features
105 route tests, matrix crawl, spec and README updated.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-24 02:19:52 +02:00

21 lines
904 B
C++

// Route: GET /metrics (Prometheus text: stats plus example metrics)
#include "support/Assert.hpp"
using namespace molo::example::test;
using molo::example::fw::Method;
int main() {
Fixture f;
f.services.metrics->inc("demo.hits", 3);
f.client->get("/health");
auto res = f.client->get("/metrics");
check(res.status == 200, "status 200");
check(contains(res.headers.get("Content-Type"), "text/plain; version=0.0.4"), "prometheus content type");
check(contains(res.body, "# TYPE molo_http_requests_total counter"), "type line");
check(contains(res.body, "molo_http_requests_total "), "request counter");
check(contains(res.body, "molo_example_demo_hits 3"), "example metric sanitized");
check(f.services.stats->total_requests() >= 2, "side effect: stats counted");
check(f.client->request(Method::Post, "/metrics").status == 405, "post is 405");
return finish("prom/metrics");
}