Vert.x - Metrics

Java Conceptuel Diagram

About

What are Application Metrics? ie Perfcounter, Performance Metrics, Operational data, Monitoring, telemetry in Vertx.

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.

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.





Discover More
Vertx Launcher Extension Custom Idea Run
Vertx - Launcher extension (Custom launcher)

The launcher has several io/vertx/core/Launcherlifecycle methods that you can override in order to add custom code that provide a way to configure the options: for the creation of a vertx or for the...



Share this page:
Follow us:
Task Runner