Hi all
When using Micrometer Metrics I can realize that my event bus is starting to have troubles delivering events. I normally send thousands of events a second over the bus, but when I enable metrics i think it starts to deadlock (sometimes taking over 30 seconds to reply to a request - i guess more, it just timeouts).
So, how do I know it is related to Micrometer Metrics? The first thing is that simply changing this to false fixes it:
@Bean
MetricsOptions metricsOptions() {
return new MicrometerMetricsOptions()
.setEnabled(true);
}
The second clue is that the thread health check realizes that the tread is blocked and dumps a stack trace like this:
io.vertx.core.VertxException: Thread blocked
at io.micrometer.core.instrument.MeterRegistry.getOrCreateMeter(MeterRegistry.java:557) ~[micrometer-core-1.0.0.jar:1.0.0]
at io.micrometer.core.instrument.MeterRegistry.registerMeterIfNecessary(MeterRegistry.java:537) ~[micrometer-core-1.0.0.jar:1.0.0]
at io.micrometer.core.instrument.MeterRegistry.registerMeterIfNecessary(MeterRegistry.java:512) ~[micrometer-core-1.0.0.jar:1.0.0]
at io.micrometer.core.instrument.MeterRegistry.gauge(MeterRegistry.java:242) ~[micrometer-core-1.0.0.jar:1.0.0]
at io.micrometer.core.instrument.Gauge$Builder.register(Gauge.java:128) ~[micrometer-core-1.0.0.jar:1.0.0]
at io.vertx.micrometer.impl.meters.Gauges.get(Gauges.java:61) ~[vertx-micrometer-metrics-3.5.4.jar:3.5.4]
at io.vertx.micrometer.impl.VertxEventBusMetrics.handlerRegistered(VertxEventBusMetrics.java:62) ~[vertx-micrometer-metrics-3.5.4.jar:3.5.4]
at io.vertx.micrometer.impl.VertxEventBusMetrics.handlerRegistered(VertxEventBusMetrics.java:32) ~[vertx-micrometer-metrics-3.5.4.jar:3.5.4]
at io.vertx.core.eventbus.impl.HandlerRegistration.setResult(HandlerRegistration.java:173) ~[vertx-core-3.5.4.jar:3.5.4]
The location where it is hanging is:
private Meter getOrCreateMeter(@Nullable DistributionStatisticConfig config,
BiFunction<Id, /*Nullable Generic*/ DistributionStatisticConfig, Meter> builder,
Id mappedId, Function<Meter.Id, ? extends Meter> noopBuilder) {
Meter m = meterMap.get(mappedId);
if (m == null) {
if (isClosed()) {
return noopBuilder.apply(mappedId);
}
--->> synchronized (meterMapLock) {
From what I understand it keeps creating the same gauge over and over again which is strange, because I would have expected that it gets created once it went over the function. One other explanation would be that creating the meter later fails so it wont be added, however I have created a conditional breakpoint and the meter is never null and successfully created.
Does anyone know what causes this issue?
BR
Yanick