Search in sources :

Example 1 with MetricsHandler

use of io.prometheus.client.vertx.MetricsHandler in project vertx-examples by vert-x3.

the class PrometheusMetricsVerticle method start.

@Override
public void start() throws Exception {
    MetricRegistry metricRegistry = SharedMetricRegistries.getOrCreate("exported");
    CollectorRegistry.defaultRegistry.register(new DropwizardExports(metricRegistry));
    // Bind metrics handler to /metrics
    Router router = Router.router(vertx);
    router.get("/metrics").handler(new MetricsHandler());
    // Start httpserver on localhost:8080
    vertx.createHttpServer().requestHandler(router::accept).listen(8080);
    // Increase counter every second
    vertx.setPeriodic(1_000L, e -> metricRegistry.counter("testCounter").inc());
}
Also used : DropwizardExports(io.prometheus.client.dropwizard.DropwizardExports) MetricRegistry(com.codahale.metrics.MetricRegistry) MetricsHandler(io.prometheus.client.vertx.MetricsHandler) Router(io.vertx.ext.web.Router)

Aggregations

MetricRegistry (com.codahale.metrics.MetricRegistry)1 DropwizardExports (io.prometheus.client.dropwizard.DropwizardExports)1 MetricsHandler (io.prometheus.client.vertx.MetricsHandler)1 Router (io.vertx.ext.web.Router)1