About
By default Vert.x does not record any metrics. Instead it provides an SPI for others to implement which can be added to the classpath.
The metrics SPI is an advanced feature which allows implementers to capture events from Vert.x in order to gather metrics.
Articles Related
Configuration
Example
VertxOptions vertxOptions = new VertxOptions()
.setMetricsOptions(metricsOptions);
Vertx vertx = Vertx.vertx(vertxOptions);
Launcher
The configuration of the metrics should (can) be implemented in a custom launcher. See Vertx - Launcher extension (Custom launcher) for an example.
Example
Dropizward
Vertx has a Metrics extension for dropwizard.
- Initialize Dropwizard metric registry
String registryName = "registry";
MetricRegistry registry = SharedMetricRegistries.getOrCreate(registryName);
SharedMetricRegistries.setDefault(registryName);
Slf4jReporter reporter = Slf4jReporter.forRegistry(registry)
.outputTo(LoggerFactory.getLogger(Launcher.class))
.convertRatesTo(TimeUnit.SECONDS)
.convertDurationsTo(TimeUnit.MILLISECONDS)
.build();
reporter.start(1, TimeUnit.MINUTES);
- Pass the registry to dropwizard
DropwizardMetricsOptions= new DropwizardMetricsOptions()
.setEnabled(true)
.setMetricRegistry(registry);
Documentation
- The API Documentation.