feat: add prometheus monitor

This commit is contained in:
2023-12-10 17:53:25 +01:00
parent 6679779927
commit a7f3ac09e0
3 changed files with 31 additions and 0 deletions

View File

@@ -1,6 +1,7 @@
use chromium::rocket::Chromium;
use nanobyte_opentelemetry::rocket::TracingFairing;
use rocket::{Rocket, Build, routes, fairing::AdHoc};
use rocket_prometheus::PrometheusMetrics;
use serde::Deserialize;
pub mod routes;
mod chromium;
@@ -24,6 +25,8 @@ pub struct DefaultPerson {
}
pub fn rocket_builder() -> Rocket<Build> {
let prometheus = PrometheusMetrics::new();
rocket::build()
.attach(TracingFairing::ignite())
.attach(Chromium::ignite())
@@ -33,8 +36,10 @@ pub fn rocket_builder() -> Rocket<Build> {
.attach(
AdHoc::config::<DefaultPerson>()
)
.attach(prometheus.clone())
.mount("/", routes![
routes::pdf::render_pdf_cv,
routes::pdf::render_html_cv
])
.mount("/metrics", prometheus)
}