feat: add prometheus monitor
This commit is contained in:
parent
6679779927
commit
a7f3ac09e0
25
Cargo.lock
generated
25
Cargo.lock
generated
@ -1731,6 +1731,7 @@ dependencies = [
|
||||
"phf",
|
||||
"reqwest",
|
||||
"rocket",
|
||||
"rocket_prometheus",
|
||||
"serde",
|
||||
"serde_json",
|
||||
"serde_yaml",
|
||||
@ -1982,6 +1983,20 @@ dependencies = [
|
||||
"yansi 1.0.0-rc.1",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "prometheus"
|
||||
version = "0.13.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "449811d15fbdf5ceb5c1144416066429cf82316e2ec8ce0c1f6f8a02e7bbcf8c"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"fnv",
|
||||
"lazy_static",
|
||||
"memchr",
|
||||
"parking_lot",
|
||||
"thiserror",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "prost"
|
||||
version = "0.11.9"
|
||||
@ -2273,6 +2288,16 @@ dependencies = [
|
||||
"uncased",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rocket_prometheus"
|
||||
version = "0.10.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "18faabccdfcd08d4501768f5b6936f6332af10496f1ea8107eb48a7766e03439"
|
||||
dependencies = [
|
||||
"prometheus",
|
||||
"rocket",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rustc-demangle"
|
||||
version = "0.1.23"
|
||||
|
@ -17,6 +17,7 @@ async-trait = "0.1.74"
|
||||
async-mutex = "1.4.0"
|
||||
tokio = { version = "1.34.0", features = ["macros"] }
|
||||
tracing = { version = "0.1.40", features = ["attributes", "std"] }
|
||||
rocket_prometheus = "0.10.0"
|
||||
yansi = "0.5.1"
|
||||
tera = "1.19.1"
|
||||
tempfile = "3.8.1"
|
||||
|
@ -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)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user