Skip to content

fix(micrometer): use okapi.metrics.enabled property during Okapi metrics init - #93

Merged
rawo merged 3 commits into
mainfrom
bugfix/issue-92
Jul 30, 2026
Merged

fix(micrometer): use okapi.metrics.enabled property during Okapi metrics init#93
rawo merged 3 commits into
mainfrom
bugfix/issue-92

Conversation

@rawo

@rawo rawo commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

#92

Init by default if missing. Log warn if explicitly set to false.

…ics init

Init by default if missing. Log warn if explicitly set to false.
Copilot AI review requested due to automatic review settings July 30, 2026 08:39

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 MetricsDisabledNotice configuration that logs a WARN when okapi.metrics.enabled=false.
  • Document okapi.metrics.enabled in 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>
Copilot AI review requested due to automatic review settings July 30, 2026 08:51

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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. |

Copilot AI review requested due to automatic review settings July 30, 2026 08:55

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated no new comments.

@rawo
rawo merged commit 3a65a14 into main Jul 30, 2026
9 checks passed
@rawo
rawo deleted the bugfix/issue-92 branch July 30, 2026 09:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants