Change condition for MeterRegistry from class to bean - #498
Change condition for MeterRegistry from class to bean#498sebastiankirsch wants to merge 3 commits into
Conversation
| @Configuration(proxyBeanMethods = false) | ||
| @ConditionalOnClass(MeterRegistry.class) | ||
| @ConditionalOnBean(MeterRegistry.class) |
There was a problem hiding this comment.
Thanks for raising this PR!
Looks like a test is failing though. Can you try changing the annotations (lines 10-11) to this?
@AutoConfiguration(after = { MetricsAutoConfiguration.class, CompositeMeterRegistryAutoConfiguration.class })
@ConditionalOnClass(MeterRegistry.class)
@ConditionalOnBean(MeterRegistry.class)This is the pattern used in a lot of meter autoconfiguration classes such as https://github.com/spring-projects/spring-boot/blob/v4.1.0/module/spring-boot-micrometer-metrics/src/main/java/org/springframework/boot/micrometer/metrics/autoconfigure/jvm/JvmMetricsAutoConfiguration.java#L59-L61
There was a problem hiding this comment.
Got it.
Using no IDE, hope this works 🤞
There was a problem hiding this comment.
Well this was failing; I guess that won't go away by the changes.
2026-07-13T16:37:44.0227979Z [ERROR] Failures:
2026-07-13T16:37:44.0228788Z [ERROR] MultiBinderIT.lambda$checkSolaceMetricsAreExposed$2:97 Multiple Exceptions (2):
2026-07-13T16:37:44.0229846Z JSON path "names"
2026-07-13T16:37:44.0230296Z Expected: a collection containing "solace.message.size.payload"
2026-07-13T16:37:44.0242505Z but: mismatches were: [was "application.ready.time", was "application.started.time", was "disk.free", was "disk.total"
, was "executor.active", was "executor.completed", was "executor.pool.core", was "executor.pool.max", was "executor.pool.size", was "executor.queue.rema
ining", was "executor.queued", was "http.server.requests.active", was "jvm.buffer.count", was "jvm.buffer.memory.used", was "jvm.buffer.total.capacity",
was "jvm.classes.loaded", was "jvm.classes.loaded.count", was "jvm.classes.unloaded", was "jvm.compilation.time", was "jvm.gc.live.data.size", was "jvm
.gc.max.data.size", was "jvm.gc.memory.allocated", was "jvm.gc.memory.promoted", was "jvm.gc.overhead", was "jvm.gc.pause", was "jvm.info", was "jvm.mem
ory.committed", was "jvm.memory.max", was "jvm.memory.usage.after.gc", was "jvm.memory.used", was "jvm.threads.daemon", was "jvm.threads.live", was "jvm
.threads.peak", was "jvm.threads.started", was "jvm.threads.states", was "logback.events", was "process.cpu.time", was "process.cpu.usage", was "process
.files.max", was "process.files.open", was "process.start.time", was "process.uptime", was "spring.cloud.function", was "spring.cloud.function.active",
was "spring.integration.channels", was "spring.integration.handlers", was "spring.integration.send", was "spring.integration.sources", was "spring.secur
ity.authorizations", was "spring.security.authorizations.active", was "spring.security.filterchains", was "spring.security.filterchains.access.exception
s.before", was "spring.security.filterchains.active", was "spring.security.filterchains.authentication.anonymous.before", was "spring.security.filtercha
ins.authorization.before", was "spring.security.filterchains.context.async.before", was "spring.security.filterchains.context.holder.before", was "sprin
g.security.filterchains.context.servlet.before", was "spring.security.filterchains.csrf.before", was "spring.security.filterchains.header.before", was "
spring.security.filterchains.logout.before", was "spring.security.filterchains.requestcache.before", was "spring.security.filterchains.session.urlencodi
ng.before", was "spring.security.http.secured.requests.active", was "system.cpu.count", was "system.cpu.usage", was "system.load.average.1m"]
2026-07-13T16:37:44.0256052Z JSON path "names"
2026-07-13T16:37:44.0256575Z Expected: a collection containing "solace.message.size.total"
2026-07-13T16:37:44.0269168Z but: mismatches were: [was "application.ready.time", was "application.started.time", was "disk.free", was "disk.total"
, was "executor.active", was "executor.completed", was "executor.pool.core", was "executor.pool.max", was "executor.pool.size", was "executor.queue.rema
ining", was "executor.queued", was "http.server.requests.active", was "jvm.buffer.count", was "jvm.buffer.memory.used", was "jvm.buffer.total.capacity",
was "jvm.classes.loaded", was "jvm.classes.loaded.count", was "jvm.classes.unloaded", was "jvm.compilation.time", was "jvm.gc.live.data.size", was "jvm
.gc.max.data.size", was "jvm.gc.memory.allocated", was "jvm.gc.memory.promoted", was "jvm.gc.overhead", was "jvm.gc.pause", was "jvm.info", was "jvm.mem
ory.committed", was "jvm.memory.max", was "jvm.memory.usage.after.gc", was "jvm.memory.used", was "jvm.threads.daemon", was "jvm.threads.live", was "jvm
.threads.peak", was "jvm.threads.started", was "jvm.threads.states", was "logback.events", was "process.cpu.time", was "process.cpu.usage", was "process
.files.max", was "process.files.open", was "process.start.time", was "process.uptime", was "spring.cloud.function", was "spring.cloud.function.active", was "spring.integration.channels", was "spring.integration.handlers", was "spring.integration.send", was "spring.integration.sources", was "spring.security.authorizations", was "spring.security.authorizations.active", was "spring.security.filterchains", was "spring.security.filterchains.access.exceptions.before", was "spring.security.filterchains.active", was "spring.security.filterchains.authentication.anonymous.before", was "spring.security.filterchains.authorization.before", was "spring.security.filterchains.context.async.before", was "spring.security.filterchains.context.holder.before", was "spring.security.filterchains.context.servlet.before", was "spring.security.filterchains.csrf.before", was "spring.security.filterchains.header.before", was "spring.security.filterchains.logout.before", was "spring.security.filterchains.requestcache.before", was "spring.security.filterchains.session.urlencoding.before", was "spring.security.http.secured.requests.active", was "system.cpu.count", was "system.cpu.usage", was "system.load.average.1m"]
There was a problem hiding this comment.
Can you try removing @Configuration(proxyBeanMethods = false)? I think it might be conflicting with @AutoConfiguration
Fixes #497