gnodet opened a new pull request, #31258:
URL: https://github.com/apache/camel/pull/31258

   ## Summary
   
   Fixes two independent bugs in `camel-micrometer-prometheus`:
   
   1. `logMetricsOnShutdown` was silently ignored when 
`enableExchangeEventNotifier=false`
   2. Unknown binder names were silently skipped in 
`BindersHelper.discoverBinders()` with no diagnostic
   
   ## Root Cause
   
   **Bug 1:** `logMetricsOnShutdown` and its related settings 
(`logMetricsOnShutdownFormat`, `logMetricsOnShutdownFilters`) were wired 
exclusively into `MicrometerExchangeEventNotifier` inside the `if 
(isEnableExchangeEventNotifier())` guard in `MicrometerPrometheus.doInit()`. 
When `enableExchangeEventNotifier=false`, the entire block is skipped: no 
`MicrometerExchangeEventNotifier` is registered, so 
`AbstractMicrometerEventNotifier.doStart()` never runs, 
`MicrometerEventNotifierService` is never created, and shutdown logging 
silently never fires.
   
   **Bug 2:** In `BindersHelper.discoverBinders()`, when a binder name is not 
found in the Jandex index (e.g. due to a typo like `jvm-memry`), the lookup 
result is an empty `Optional` and the name is simply skipped with no log 
output. Users have no way to discover the misconfiguration at startup.
   
   ## Fix
   
   **Bug 1:** Added an `else if (isLogMetricsOnShutdown())` branch after the 
`enableExchangeEventNotifier` block. When `enableExchangeEventNotifier=false` 
but `logMetricsOnShutdown=true`, a `MicrometerEventNotifierService` is created 
and registered directly on the `CamelContext`, preserving all shutdown logging 
settings.
   
   **Bug 2:** Added a `LOG.warn(...)` call when a binder name fails to match 
any known `MeterBinder` implementation, logging the original (un-normalized) 
name the user configured.
   
   ## Tests
   
   - `MicrometerPrometheusLogMetricsOnShutdownTest`: three unit tests covering 
the fixed path (`enableExchangeEventNotifier=false` + 
`logMetricsOnShutdown=true` → `MicrometerEventNotifierService` registered), the 
unchanged path (`enableExchangeEventNotifier=true`), and the no-overhead case 
(both false → no service).
   - `BindersHelperTest`: three unit tests verifying that known binder names 
resolve correctly and unknown names are excluded from the returned list (while 
producing a warning).
   
   Fixes https://issues.apache.org/jira/browse/CAMEL-28007
   
   ---
   _Hermes Agent (Claude Sonnet 4.6) on behalf of Guillaume Nodet_
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to