Some projects have more than one actix_web Server (for example, to separate public and private APIs). In this case user might not want to expose metrics endpoint on public server and would like to have one only on private server. I suggest making endpoint optional:
let public_metrics = PrometheusMetrics::new("public", None);
let private_metrics = PrometheusMetrics::new("private", Some("/metrics"));
Also for projects with multiple actix_web servers it might be useful to have one metrics endpoint for the whole project => it might be useful to share one Registry instance among multiple middlewares:
let r = Registry::new();
let public_metrics =
PrometheusMetrics::new_with_registry(r.clone(), "public", None).unwrap();
let private_metrics =
PrometheusMetrics::new_with_registry(r.clone(), "private", Some("/metrics")).unwrap();
This way middleware can be used in projects with one or more actix_web Servers out of the box
Some projects have more than one actix_web
Server
(for example, to separate public and private APIs). In this case user might not want to expose metrics endpoint on public server and would like to have one only on private server. I suggest making endpoint optional:Also for projects with multiple actix_web servers it might be useful to have one metrics endpoint for the whole project => it might be useful to share one
Registry
instance among multiple middlewares:This way middleware can be used in projects with one or more actix_web
Server
s out of the box