-
Notifications
You must be signed in to change notification settings - Fork 2.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Possibility to use io.vertx.core.VertxBuilder inside io.vertx.core.impl.launcher.VertxLifecycleHooks #5388
Conversation
io.vertx.core.VertxBuilder and possibility to create io.vertx.core.impl.VertxBuilder from it related code cleanup and removed code duplication
io.vertx.core.VertxBuilder and possibility to create io.vertx.core.impl.VertxBuilder from it related code cleanup and removed code duplication
Can you elaborate about why this is not possible? Maybe with a small snippet? |
It's possible to avoid the deprecated method call doing this: @Override
public VertxBuilder createVertxBuilder(JsonObject config) {
PrometheusMeterRegistry registry = new PrometheusMeterRegistry(PrometheusConfig.DEFAULT);
CollectorRegistry prometheusClientRegistry = new CollectorRegistry();
registry = new PrometheusMeterRegistry(PrometheusConfig.DEFAULT, prometheusClientRegistry, Clock.SYSTEM);
VertxBuilder vertxBuilder = super.createVertxBuilder(config);
VertxOptions options = vertxBuilder.options();
options.setMetricsOptions(new MicrometerMetricsOptions()
.setPrometheusOptions(new VertxPrometheusOptions().setEnabled(true)
.setStartEmbeddedServer(true)
.setEmbeddedServerOptions(new HttpServerOptions().setPort(8888))
.setEmbeddedServerEndpoint("/metrics/vertx"))
.setEnabled(true));
vertxBuilder.metrics(new MicrometerMetricsFactory(registry).metrics(options));
return vertxBuilder;
} Besides, it's code that's similar to what you will have when upgrading to Vert.x 5 |
Can you try this and tell us if that suits your needs? |
@tsegismont tested, proposed solution works |
Thank you for letting us know! |
Vertx 4.5.10 introduced new "Deprecations and breaking changes", especially: Deprecate setting a MeterRegistry on MicrometerMetricsOptions
https://github.com/vert-x3/wiki/wiki/4.5.10-Deprecations-and-breaking-changes
The new way to configure "MicrometerMetricsFactory" is to use io.vertx.core.VertxBuilder.withMetrics(...) method
But there is no possibility to do this from "io.vertx.core.Launcher" - because only "io.vertx.core.VertxOptions" are accessible for configuration purposes, which is not enough now and code warn about usage of deprecated "io.vertx.micrometer.MicrometerMetricsOptions.setMicrometerRegistry(MeterRegistry)"
Vertx 4.5.11 introduced new method for customizing VertxBuilder inside "io.vertx.core.impl.launcher.VertxLifecycleHooks"
#5288
But this method allowing to customize internal "io.vertx.core.impl.VertxBuilder" which is not helping to fix deprecations
Currently "io.vertx.core.VertxBuilder" have one implementation, inlined in Vertx class, which have private method "internalBuilder()" for is creating internal VertxBuilder with provided configuration and initializing it
This PR doing the next:
This is enough to fix new deprecations from inside Launcher API to configure all required things that now require public VertxBuilder by overriding "io.vertx.core.impl.launcher.VertxLifecycleHooks.createVertxBuilder(JsonObject)" and using it in the same way as in default implementation