{"repo":"nlopes/actix-web-prom","free":true,"listed":false,"github":"https://github.com/nlopes/actix-web-prom","clone":"git clone https://github.com/nlopes/actix-web-prom.git","description":"Actix-web middleware to expose Prometheus metrics","language":"Rust","stars":110,"topics":["prometheus","prometheus-metrics","middleware","actix-web"],"license":"MIT","category":"analytics","readme_excerpt":"actix-web-prom Prometheus instrumentation for actix-web. This middleware is heavily influenced by the work in sd2k/rocket prometheus. We track the same default metrics and allow for adding user defined metrics. By default two metrics are tracked (this assumes the namespace actix web prom ): - actix web prom http requests total (labels: endpoint, method, status): the total number of HTTP requests handled by the actix HttpServer. - actix web prom http requests duration seconds (labels: endpoint, method, status): the request duration for all HTTP requests handled by the actix HttpServer. Usage First add actix-web-prom to your Cargo.toml : You then instantiate the prometheus middleware and pass it to .wrap() : Using the above as an example, a few things are worth mentioning: - api is the metrics namespace - /metrics will be auto exposed (GET requests only) with Content-Type header content-type: text/plain; version=0.0.4; charset=utf-8 - Some(labels) is used to add fixed labels to the metrics; None can be passed instead if no additional labels are necessary. A call to the /metrics endpoint will expose your metrics: Features If you enable process feature of this crate, default process metrics will also be collected. Default process metrics Custom metrics You instantiate PrometheusMetrics and then use its .registry to register your custom metric (in this case, we use a IntCounterVec ). Then you can pass this counter through .data() to have it available within the resource responder.","default_branch":null,"files":null,"tree":[],"storefront":"/r/nlopes","claimed":false,"request_supported":{"post":"https://gitbuyer.com/r/nlopes/actix-web-prom/request-supported","requests":0},"note":"indexed from public GitHub; nothing is for sale on this page. Clone it from GitHub. Paid listings live at /search."}