From 764d19570ceff8bd11d18ada3d2798f895da2da7 Mon Sep 17 00:00:00 2001 From: Vika Date: Fri, 6 Aug 2021 11:44:46 +0300 Subject: Added Prometheus instrumentation I need to instrument the mobc library used for the Redis connection pool, but that can be done later since I am somewhat tired. I don't remember how much I've worked and I need a break... >.< --- src/lib.rs | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'src/lib.rs') diff --git a/src/lib.rs b/src/lib.rs index 6a62dcc..77a6c11 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -4,6 +4,7 @@ mod database; mod frontend; mod indieauth; mod micropub; +mod metrics; use crate::indieauth::IndieAuthMiddleware; use crate::micropub::CORSMiddleware; @@ -42,6 +43,7 @@ where .build()) }); app.at("/") + .with(CORSMiddleware {}) .with(frontend::ErrorHandlerMiddleware {}) .get(frontend::mainpage) .post(frontend::onboarding_receiver); @@ -54,7 +56,13 @@ where app.at("/coffee") .with(frontend::ErrorHandlerMiddleware {}) .get(frontend::coffee); + // TODO make sure the health check actually checks the backend or something + // otherwise it'll get false-negatives for application faults like resource + // exhaustion app.at("/health").get(|_| async { Ok("OK") }); + app.at("/metrics").get(metrics::gather); + + app.with(metrics::InstrumentationMiddleware {}); app } -- cgit 1.4.1