prometheus2 1.0.1
Prometheus collectors and metrics ... modernized
To use this package, run the following command in your project's root directory:
Manual usage
Put the following dependency into your project's dependences section:
Prometheus2 for D
This library helps you expose your metrics in a Prometheus compatible format. The core library has no external dependencies which makes it easy to integrate with other solutions.
Example
This is an example using Vibe.d to export the number of page hits. To import prometheus.vibe put "prometheus:vibe": into the dub.json dependencies.
import prometheus.counter;
import prometheus.registry;
import prometheus.vibe;
import vibe.d;
void main()
{
auto settings = new HTTPServerSettings;
settings.port = 10000;
//create counter and register with global registry
Counter c = new Counter("hit_count", "Shows the number of site hits", null);
c.register;
//start routes for Vibe.d
auto router = new URLRouter;
router.any("*", (HTTPServerRequest req, HTTPServerResponse res) {
c.inc;
});
router.get("/", (HTTPServerRequest req, HTTPServerResponse res) {
res.writeBody(cast(ubyte[])"hello, world!");
});
router.get("/metrics", handleMetrics(Registry.global));
listenHTTP(settings, router);
runApplication;
}
TODO
- [x] Counter
- [x] Gauge
- [x] Histogram
- [ ] Summary
- [ ] Default Dlang metrics (GC, etc...)
- [x] Vibe.d integration
- Registered by Robert Schadek
- 1.0.1 released a day ago
- burner/prometheus-d
- MPL-2.0
- Authors:
- Sub packages:
- prometheus2:vibe
- Dependencies:
- none
- Versions:
-
1.0.1 2024-Nov-19 1.0.0 2024-Nov-19 ~master 2024-Nov-19 ~modernize 2024-Nov-19 - Download Stats:
-
-
6 downloads today
-
16 downloads this week
-
16 downloads this month
-
16 downloads total
-
- Score:
- 0.9
- Short URL:
- prometheus2.dub.pm