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());
}
Aggregations