Add /metrics endpoint for Prometheus (#724)

This commit is contained in:
Jackson Kruger
2023-10-06 17:58:02 -05:00
committed by GitHub
parent 259c5ef3d0
commit dfa43f3c5a
3 changed files with 52 additions and 4 deletions

View File

@@ -1,4 +1,5 @@
use actix_web::{App, HttpServer};
use actix_web_prom::PrometheusMetricsBuilder;
use env_logger::Env;
use labrinth::database::redis::RedisPool;
use labrinth::file_hosting::S3Host;
@@ -88,6 +89,11 @@ async fn main() -> std::io::Result<()> {
let store = MemoryStore::new();
let prometheus = PrometheusMetricsBuilder::new("labrinth")
.endpoint("/metrics")
.build()
.expect("Failed to create prometheus metrics middleware");
info!("Starting Actix HTTP server!");
let labrinth_config = labrinth::app_setup(
@@ -101,6 +107,7 @@ async fn main() -> std::io::Result<()> {
// Init App
HttpServer::new(move || {
App::new()
.wrap(prometheus.clone())
.wrap(actix_web::middleware::Compress::default())
.wrap(
RateLimiter::new(MemoryStoreActor::from(store.clone()).start())