Skip to content

andrewbenton/prometheus-d

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

24 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Prometheus 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

  • Counter
  • Gauge
  • Histogram
  • Summary
  • Default Dlang metrics (GC, etc...)
  • Vibe.d integration
  • Hunt integration

About

Prometheus client library for Dlang

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 3

  •  
  •  
  •  

Languages