Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
CollectorRegistry collectorRegistry = new CollectorRegistry();
PrometheusMeterRegistry micrometerRegistry =
new PrometheusMeterRegistry(PrometheusConfig.DEFAULT, collectorRegistry, Clock.SYSTEM);
micrometerRegistry
.config()
.commonTags()
.commonTags(
"application",
metadata.getName(),
"env",
metadata.getEnv(),
"version",
metadata.getVersion());
PrometheusMeterRegistry micrometerRegistry2 =
new PrometheusMeterRegistry(PrometheusConfig.DEFAULT, collectorRegistry, Clock.SYSTEM);
micrometerRegistry2
.config()
.commonTags()
.commonTags(
"application",
metadata.getName() + "-1",
"env",
metadata.getEnv(),
"version",
metadata.getVersion());
System.setProperty(
"vertx.logger-delegate-factory-class-name",
"io.vertx.core.logging.Log4j2LogDelegateFactory");
Vertx vertx =
Vertx.vertx(
new VertxOptions()
.setPreferNativeTransport(true)
.setWorkerPoolSize(vertxConfig.getWorkerPoolSize())
.setEventLoopPoolSize(vertxConfig.getEventLoopPoolSize())
.setMaxEventLoopExecuteTimeUnit(TimeUnit.MILLISECONDS)
.setMaxEventLoopExecuteTime(vertxConfig.getMaxEventLoopExecuteTimeMs())
.setMaxWorkerExecuteTimeUnit(TimeUnit.MILLISECONDS)
.setMaxWorkerExecuteTime(vertxConfig.getMaxWorkerExecuteTimeMs())
.setMetricsOptions(
new MicrometerMetricsOptions()
.setMicrometerRegistry(micrometerRegistry)
.setJvmMetricsEnabled(true)
.setPrometheusOptions(
new VertxPrometheusOptions()
.setEnabled(true)
.setPublishQuantiles(true)
.setStartEmbeddedServer(true)
.setEmbeddedServerOptions(
new HttpServerOptions()
.setPort(vertxConfig.getPrometheusPort()))
.setEmbeddedServerEndpoint("/metrics"))
.setEnabled(true)));
Vertx vertx2 =
Vertx.vertx(
new VertxOptions()
.setPreferNativeTransport(true)
.setWorkerPoolSize(vertxConfig.getWorkerPoolSize())
.setEventLoopPoolSize(vertxConfig.getEventLoopPoolSize())
.setMaxEventLoopExecuteTimeUnit(TimeUnit.MILLISECONDS)
.setMaxEventLoopExecuteTime(vertxConfig.getMaxEventLoopExecuteTimeMs())
.setMaxWorkerExecuteTimeUnit(TimeUnit.MILLISECONDS)
.setMaxWorkerExecuteTime(vertxConfig.getMaxWorkerExecuteTimeMs())
.setMetricsOptions(
new MicrometerMetricsOptions()
.setMicrometerRegistry(micrometerRegistry2)
.setJvmMetricsEnabled(true)
.setRegistryName("RS")
.setPrometheusOptions(
new VertxPrometheusOptions().setEnabled(true).setPublishQuantiles(true))
.setEnabled(true)));
vertx2.setPeriodic(
100,
l -> {
Counter.builder("aaaaaa").register(BackendRegistries.getNow("RS")).increment();
});
vertx.setPeriodic(
100,
l -> {
Counter.builder("bbbb").register(micrometerRegistry).increment();
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment