fix(micrometer): use okapi.metrics.enabled property during Okapi metrics init - #93
Conversation
…ics init Init by default if missing. Log warn if explicitly set to false.
There was a problem hiding this comment.
Pull request overview
Adds an explicit Spring Boot property toggle for Okapi’s Micrometer auto-configuration so okapi.metrics.enabled=false is no longer silently ignored, and provides an actionable startup warning when metrics are opted out.
Changes:
- Gate Okapi Micrometer bean registration behind
@ConditionalOnProperty(okapi.metrics.enabled=true, matchIfMissing=true). - Add a
MetricsDisabledNoticeconfiguration that logs a WARN whenokapi.metrics.enabled=false. - Document
okapi.metrics.enabledin the README and add regression tests for enabled/disabled/invalid property values.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| README.md | Documents the new okapi.metrics.enabled opt-out and its effect. |
| okapi-spring-boot/src/main/kotlin/com/softwaremill/okapi/springboot/OkapiMicrometerAutoConfiguration.kt | Implements conditional bean registration and the WARN-on-disabled notice. |
| okapi-spring-boot/src/test/kotlin/com/softwaremill/okapi/springboot/OkapiMicrometerAutoConfigurationTest.kt | Adds coverage for default/true/false/garbage behaviors and verifies WARN logging. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> Signed-off-by: Rafał Wokacz <rafal.wokacz@gmail.com>
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 3 out of 3 changed files in this pull request and generated no new comments.
Comments suppressed due to low confidence (3)
okapi-spring-boot/src/main/kotlin/com/softwaremill/okapi/springboot/OkapiMicrometerAutoConfiguration.kt:131
- The disable-path WARN currently states that no okapi.* counters/timers/gauges "will be published", which can be untrue if an application registers MicrometerOutboxListener/MicrometerOutboxMetrics manually (or via other config). It’s safer to phrase this as “Okapi will not auto-register …” rather than asserting what the whole application will (not) publish.
companion object {
private val logger = LoggerFactory.getLogger(OkapiMicrometerAutoConfiguration::class.java)
}
}
okapi-spring-boot/src/main/kotlin/com/softwaremill/okapi/springboot/OkapiMicrometerAutoConfiguration.kt:75
- The INFO log in MetricsConfiguration runs on every startup when metrics are enabled (the default) and claims beans "register" / metrics "will be published" even though the beans are still gated by @ConditionalOnMissingBean. This adds log noise and can be misleading in overridden/partial-metrics setups.
@ConditionalOnMissingBean
fun micrometerOutboxListener(registry: MeterRegistry): MicrometerOutboxListener = MicrometerOutboxListener(registry)
@Bean
@ConditionalOnMissingBean
README.md:217
- The README says this flag disables
okapi-micrometer“entirely”, but it only disables Okapi’s Spring Boot auto-configuration; users can still register MicrometerOutboxListener/MicrometerOutboxMetrics manually. Documenting it as an auto-config opt-out avoids overpromising behavior.
| `okapi.metrics.enabled` | `true` | Set `false` to disable `okapi-micrometer` entirely — no counters, timers, gauges, or store polling. Logs a startup warning when disabled. |
#92
Init by default if missing. Log warn if explicitly set to false.