This is an automated email from the ASF dual-hosted git repository.

jamesnetherton pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git


The following commit(s) were added to refs/heads/main by this push:
     new 7f0edcae3bd7 CAMEL-23811: Fix app.info gauge returning NaN due to weak 
reference
7f0edcae3bd7 is described below

commit 7f0edcae3bd781eb1d57d9a34b2e2dfa43f6b471
Author: James Netherton <[email protected]>
AuthorDate: Mon Jun 22 15:11:02 2026 +0100

    CAMEL-23811: Fix app.info gauge returning NaN due to weak reference
    
    Co-authored-by: Claude Opus 4.6 (1M context) <[email protected]>
---
 .../component/micrometer/json/AbstractMicrometerService.java   | 10 ++++------
 .../MicrometerRoutePolicyMulticastSubRouteTest.java            | 10 ++++++++--
 2 files changed, 12 insertions(+), 8 deletions(-)

diff --git 
a/components/camel-micrometer/src/main/java/org/apache/camel/component/micrometer/json/AbstractMicrometerService.java
 
b/components/camel-micrometer/src/main/java/org/apache/camel/component/micrometer/json/AbstractMicrometerService.java
index 80bc6b7d3a86..fe1c5d942163 100644
--- 
a/components/camel-micrometer/src/main/java/org/apache/camel/component/micrometer/json/AbstractMicrometerService.java
+++ 
b/components/camel-micrometer/src/main/java/org/apache/camel/component/micrometer/json/AbstractMicrometerService.java
@@ -16,7 +16,6 @@
  */
 package org.apache.camel.component.micrometer.json;
 
-import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.Map;
 import java.util.Optional;
@@ -271,14 +270,13 @@ public class AbstractMicrometerService extends 
ServiceSupport {
                 // If not other runtime is available, we assume we're on Camel 
main
                 rt = Optional.of(new RuntimeInfo(RuntimeInfo.MAIN, 
getCamelContext().getVersion()));
             }
-            meterRegistry.gaugeCollectionSize(
-                    APP_INFO_METER_NAME,
-                    Tags.of(
+            Gauge.builder(APP_INFO_METER_NAME, () -> 0.0)
+                    .tags(Tags.of(
                             "camel.version", getCamelContext().getVersion(),
                             "camel.context", getCamelContext().getName(),
                             "camel.runtime.provider", rt.get().runtimeProvider,
-                            "camel.runtime.version", rt.get().runtimeVersion),
-                    new ArrayList<String>());
+                            "camel.runtime.version", rt.get().runtimeVersion))
+                    .register(meterRegistry);
         }
     }
 
diff --git 
a/components/camel-micrometer/src/test/java/org/apache/camel/component/micrometer/routepolicy/MicrometerRoutePolicyMulticastSubRouteTest.java
 
b/components/camel-micrometer/src/test/java/org/apache/camel/component/micrometer/routepolicy/MicrometerRoutePolicyMulticastSubRouteTest.java
index ed18d5c59ec0..6824279c8e4a 100644
--- 
a/components/camel-micrometer/src/test/java/org/apache/camel/component/micrometer/routepolicy/MicrometerRoutePolicyMulticastSubRouteTest.java
+++ 
b/components/camel-micrometer/src/test/java/org/apache/camel/component/micrometer/routepolicy/MicrometerRoutePolicyMulticastSubRouteTest.java
@@ -118,10 +118,16 @@ public class MicrometerRoutePolicyMulticastSubRouteTest 
extends AbstractMicromet
                             "Counter " + counter.getId() + " should have count 
of " + count);
                     break;
                 }
-                case APP_INFO_METER_NAME:
+                case APP_INFO_METER_NAME: {
                     Gauge gauge = (Gauge) meter;
-                    // It's enough to validate it does not throw a class cast 
exception
+                    Meter.Id id = gauge.getId();
+                    assertEquals(0.0, gauge.value(), "app.info gauge should 
have a stable value of 0.0");
+                    assertEquals(context.getVersion(), 
id.getTag("camel.version"));
+                    assertEquals(context.getName(), 
id.getTag("camel.context"));
+                    assertEquals("Main", id.getTag("camel.runtime.provider"));
+                    assertEquals(context.getVersion(), 
id.getTag("camel.runtime.version"));
                     break;
+                }
                 default: {
                     fail("Unexpected meter " + meterName);
                     break;

Reply via email to