add requests_received metrics

Signed-off-by: eternal-flame-AD <yume@yumechi.jp>
This commit is contained in:
ゆめ 2024-11-22 14:29:28 -06:00
parent 7e31f167ea
commit 5c0d12cafe
No known key found for this signature in database

View file

@ -98,12 +98,24 @@ fn main() {
&["status", "postprocess"], &["status", "postprocess"],
) )
.expect("Failed to create prometheus counter"); .expect("Failed to create prometheus counter");
let counter_requests_received = GenericCounterVec::<AtomicU64>::new(
Opts::new(
"misskey_media_proxy_requests_received",
"Number of requests received",
),
&[],
)
.expect("Failed to create prometheus counter");
reg.register(Box::new(counter_requests_served.clone())) reg.register(Box::new(counter_requests_served.clone()))
.expect("Failed to register prometheus counter"); .expect("Failed to register prometheus counter");
reg.register(Box::new(counter_requests_received.clone()))
.expect("Failed to register prometheus counter");
router = router router = router
.layer(middleware::from_fn(move |req, mut next: Next| { .layer(middleware::from_fn(move |req, mut next: Next| {
counter_requests_received.with_label_values(&[]).inc();
let counter_requests_served = counter_requests_served.clone(); let counter_requests_served = counter_requests_served.clone();
next.call(req) next.call(req)
.map_ok(move |res| { .map_ok(move |res| {