You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by "oscerd (via GitHub)" <gi...@apache.org> on 2026/10/19 10:06:43 UTC

[PR] CAMEL-25804: camel-pqc - keep the stateful key gauge supplier reachable [camel]

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

   Fixes [CAMEL-25804](https://issues.apache.org/jira/browse/CAMEL-25804).
   
   ## Problem
   
   ```java
   statefulKeyGauge = Gauge.builder(METRIC_STATEFUL_REMAINING, remainingSupplier, LongSupplier::getAsLong)
   ```
   
   Micrometer holds the state object of a gauge through a **weak** reference. From the `micrometer-core` jar:
   
   ```
   public class io.micrometer.core.instrument.internal.DefaultGauge<T> ... {
     private final java.lang.ref.WeakReference<T> ref;
   ```
   
   The only reference to the supplier was the inline lambda the producer passes in at `PQCProducer`:
   
   ```java
   metrics.registerStatefulKeyGauge(signatureAlgorithm, () -> {
       KeyPair kp = getRuntimeKeyPair();
       return kp != null && kp.getPrivate() != null ? getStatefulKeyRemaining(kp.getPrivate()) : -1;
   });
   ```
   
   Neither the producer nor `PQCMicrometerMetrics` kept it — only the `Gauge` was stored. Once collected, the gauge
   reports `NaN`, so `camel.pqc.stateful.key.remaining` — the one metric that tells an operator a one-time-use LMS/XMSS
   key is running out of signatures — silently goes dark.
   
   ## Fix
   
   The suppliers are held in a map for the lifetime of the metrics instance.
   
   The single `statefulKeyGauge` field is also replaced by a map keyed by algorithm: a second
   `registerStatefulKeyGauge` call overwrote the field and left the first gauge registered but unreachable, so
   `close()` could not remove it.
   
   ## Deliberately not changed
   
   A `MeterRegistry` is shared and identifies meters by id, so two producers whose `operation|algorithm|outcome` tags
   coincide share one meter instance — closing either de-registers it for both. Fixing that means giving each producer a
   distinguishing tag, which changes the published tag set and is a user-visible decision. I recorded it in the class
   javadoc rather than changing it unilaterally; happy to follow up if you want it.
   
   ## Tests
   
   New `PQCMicrometerMetricsTest`:
   
   - `theStatefulGaugeKeepsReportingAfterTheSupplierBecomesUnreachable` — against `main` this reads
     `expected: <42.0> but was: <NaN>`. It collects until a canary `WeakReference` is actually cleared and asserts that
     it was, so the test cannot pass by a collection simply not having run;
   - `registeringASecondGaugeDoesNotOrphanTheFirst` — against `main`, `close()` leaves the first gauge registered;
   - `operationCountersAreRecordedAndRemovedOnClose` and a no-op guard, covering the rest of the class, which had no
     unit test at all.
   
   Full `camel-pqc` build green: 243 tests, 0 failures.
   
   No upgrade-guide entry: a metric that was `NaN` now reports a value is a fix, not a migration step.
   
   ---
   _Reported, analysed and fixed by Claude Code (AI agent) on behalf of @oscerd._
   
   🤖 Generated with [Claude Code](https://claude.com/claude-code)


-- 
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: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] CAMEL-25804: camel-pqc - keep the stateful key gauge supplier reachable [camel]

Posted by "oscerd (via GitHub)" <gi...@apache.org>.
oscerd commented on code in PR #28102:
URL: https://github.com/apache/camel/pull/28102#discussion_r4314491770


##########
components/camel-pqc/src/test/java/org/apache/camel/component/pqc/metrics/PQCMicrometerMetricsTest.java:
##########
@@ -0,0 +1,118 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.pqc.metrics;
+
+import java.lang.ref.WeakReference;
+import java.util.concurrent.atomic.AtomicLong;
+
+import io.micrometer.core.instrument.MeterRegistry;
+import io.micrometer.core.instrument.simple.SimpleMeterRegistry;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
+
+/**
+ * Micrometer holds the state object of a gauge through a weak reference, so the remaining-signatures supplier has to be
+ * kept reachable by this class or the gauge silently degrades to NaN.
+ */
+class PQCMicrometerMetricsTest {
+
+    @Test
+    void theStatefulGaugeKeepsReportingAfterTheSupplierBecomesUnreachable() {
+        MeterRegistry registry = new SimpleMeterRegistry();
+        PQCMicrometerMetrics metrics = new PQCMicrometerMetrics(registry);
+
+        AtomicLong remaining = new AtomicLong(42);
+        // the lambda is reachable only through the metrics instance from here on
+        metrics.registerStatefulKeyGauge("LMS", remaining::get);
+
+        forceGc();
+
+        assertEquals(42.0,
+                registry.get(PQCMicrometerMetrics.METRIC_STATEFUL_REMAINING).tag("algorithm", "LMS").gauge().value(),
+                "the gauge must still read the supplier after a collection");
+
+        remaining.set(7);
+        assertEquals(7.0,
+                registry.get(PQCMicrometerMetrics.METRIC_STATEFUL_REMAINING).tag("algorithm", "LMS").gauge().value(),
+                "the gauge must track the live value, not a snapshot");
+    }
+
+    @Test
+    void registeringASecondGaugeDoesNotOrphanTheFirst() {
+        MeterRegistry registry = new SimpleMeterRegistry();
+        PQCMicrometerMetrics metrics = new PQCMicrometerMetrics(registry);
+
+        metrics.registerStatefulKeyGauge("LMS", () -> 10);
+        metrics.registerStatefulKeyGauge("XMSS", () -> 20);
+
+        assertEquals(10.0,
+                registry.get(PQCMicrometerMetrics.METRIC_STATEFUL_REMAINING).tag("algorithm", "LMS").gauge().value());
+        assertEquals(20.0,
+                registry.get(PQCMicrometerMetrics.METRIC_STATEFUL_REMAINING).tag("algorithm", "XMSS").gauge().value());
+
+        metrics.close();
+
+        assertNull(registry.find(PQCMicrometerMetrics.METRIC_STATEFUL_REMAINING).tag("algorithm", "LMS").gauge(),
+                "close() must remove every gauge it registered, not only the last one");
+        assertNull(registry.find(PQCMicrometerMetrics.METRIC_STATEFUL_REMAINING).tag("algorithm", "XMSS").gauge());
+    }
+
+    @Test
+    void operationCountersAreRecordedAndRemovedOnClose() {
+        MeterRegistry registry = new SimpleMeterRegistry();
+        PQCMicrometerMetrics metrics = new PQCMicrometerMetrics(registry);
+
+        metrics.recordOperation("sign", "MLDSA", true);
+        metrics.recordOperation("sign", "MLDSA", true);
+        metrics.recordOperation("sign", "MLDSA", false);
+
+        assertEquals(2.0, registry.get(PQCMicrometerMetrics.METRIC_OPERATIONS)
+                .tag("operation", "sign").tag("algorithm", "MLDSA").tag("outcome", "success").counter().count());
+        assertEquals(1.0, registry.get(PQCMicrometerMetrics.METRIC_OPERATIONS)
+                .tag("operation", "sign").tag("algorithm", "MLDSA").tag("outcome", "failure").counter().count());
+
+        metrics.close();
+
+        assertNull(registry.find(PQCMicrometerMetrics.METRIC_OPERATIONS).counter());
+    }
+
+    @Test
+    void noMeterRegistryYieldsTheNoopImplementation() {
+        assertNotNull(PQCMetrics.NOOP);
+        // the no-op must tolerate every call without a registry behind it
+        PQCMetrics.NOOP.recordOperation("sign", "MLDSA", true);
+        PQCMetrics.NOOP.registerStatefulKeyGauge("LMS", () -> 1);
+        PQCMetrics.NOOP.close();
+        assertFalse(PQCMetrics.NOOP instanceof PQCMicrometerMetrics);
+    }
+
+    /**
+     * Collects until a canary weak reference is actually cleared, so the assertion that follows is about the gauge
+     * rather than about whether a collection happened to run.
+     */
+    private static void forceGc() {
+        WeakReference<Object> canary = new WeakReference<>(new Object());
+        for (int i = 0; i < 100 && canary.get() != null; i++) {
+            System.gc();
+        }
+        assertNull(canary.get(), "no garbage collection was observed, the test below would prove nothing");

Review Comment:
   Fixed in 6b8b759 — the canary check is now `assumeTrue`, so the test skips under `-XX:+DisableExplicitGC` instead of failing.
   
   _Claude Code on behalf of @oscerd_



##########
components/camel-pqc/src/test/java/org/apache/camel/component/pqc/metrics/PQCMicrometerMetricsTest.java:
##########
@@ -0,0 +1,118 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.pqc.metrics;
+
+import java.lang.ref.WeakReference;
+import java.util.concurrent.atomic.AtomicLong;
+
+import io.micrometer.core.instrument.MeterRegistry;
+import io.micrometer.core.instrument.simple.SimpleMeterRegistry;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
+
+/**
+ * Micrometer holds the state object of a gauge through a weak reference, so the remaining-signatures supplier has to be
+ * kept reachable by this class or the gauge silently degrades to NaN.
+ */
+class PQCMicrometerMetricsTest {
+
+    @Test
+    void theStatefulGaugeKeepsReportingAfterTheSupplierBecomesUnreachable() {
+        MeterRegistry registry = new SimpleMeterRegistry();
+        PQCMicrometerMetrics metrics = new PQCMicrometerMetrics(registry);
+
+        AtomicLong remaining = new AtomicLong(42);
+        // the lambda is reachable only through the metrics instance from here on
+        metrics.registerStatefulKeyGauge("LMS", remaining::get);
+
+        forceGc();
+
+        assertEquals(42.0,
+                registry.get(PQCMicrometerMetrics.METRIC_STATEFUL_REMAINING).tag("algorithm", "LMS").gauge().value(),
+                "the gauge must still read the supplier after a collection");
+
+        remaining.set(7);
+        assertEquals(7.0,
+                registry.get(PQCMicrometerMetrics.METRIC_STATEFUL_REMAINING).tag("algorithm", "LMS").gauge().value(),
+                "the gauge must track the live value, not a snapshot");
+    }
+
+    @Test
+    void registeringASecondGaugeDoesNotOrphanTheFirst() {
+        MeterRegistry registry = new SimpleMeterRegistry();
+        PQCMicrometerMetrics metrics = new PQCMicrometerMetrics(registry);
+
+        metrics.registerStatefulKeyGauge("LMS", () -> 10);
+        metrics.registerStatefulKeyGauge("XMSS", () -> 20);
+
+        assertEquals(10.0,
+                registry.get(PQCMicrometerMetrics.METRIC_STATEFUL_REMAINING).tag("algorithm", "LMS").gauge().value());
+        assertEquals(20.0,
+                registry.get(PQCMicrometerMetrics.METRIC_STATEFUL_REMAINING).tag("algorithm", "XMSS").gauge().value());
+
+        metrics.close();
+
+        assertNull(registry.find(PQCMicrometerMetrics.METRIC_STATEFUL_REMAINING).tag("algorithm", "LMS").gauge(),
+                "close() must remove every gauge it registered, not only the last one");
+        assertNull(registry.find(PQCMicrometerMetrics.METRIC_STATEFUL_REMAINING).tag("algorithm", "XMSS").gauge());
+    }
+
+    @Test
+    void operationCountersAreRecordedAndRemovedOnClose() {
+        MeterRegistry registry = new SimpleMeterRegistry();
+        PQCMicrometerMetrics metrics = new PQCMicrometerMetrics(registry);
+
+        metrics.recordOperation("sign", "MLDSA", true);
+        metrics.recordOperation("sign", "MLDSA", true);
+        metrics.recordOperation("sign", "MLDSA", false);
+
+        assertEquals(2.0, registry.get(PQCMicrometerMetrics.METRIC_OPERATIONS)
+                .tag("operation", "sign").tag("algorithm", "MLDSA").tag("outcome", "success").counter().count());
+        assertEquals(1.0, registry.get(PQCMicrometerMetrics.METRIC_OPERATIONS)
+                .tag("operation", "sign").tag("algorithm", "MLDSA").tag("outcome", "failure").counter().count());
+
+        metrics.close();
+
+        assertNull(registry.find(PQCMicrometerMetrics.METRIC_OPERATIONS).counter());
+    }
+
+    @Test
+    void noMeterRegistryYieldsTheNoopImplementation() {

Review Comment:
   Fixed in 6b8b759 — the test now builds a `DefaultCamelContext` with no `MeterRegistry` bound and asserts `PQCMicrometerMetrics.create(context)` returns `PQCMetrics.NOOP`, then exercises the no-op. Renamed to `aContextWithoutAMeterRegistryYieldsTheNoopImplementation`.
   
   _Claude Code on behalf of @oscerd_



-- 
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: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] CAMEL-25804: camel-pqc - keep the stateful key gauge supplier reachable [camel]

Posted by "davsclaus (via GitHub)" <gi...@apache.org>.
davsclaus commented on code in PR #28102:
URL: https://github.com/apache/camel/pull/28102#discussion_r4313847651


##########
components/camel-pqc/src/test/java/org/apache/camel/component/pqc/metrics/PQCMicrometerMetricsTest.java:
##########
@@ -0,0 +1,118 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.pqc.metrics;
+
+import java.lang.ref.WeakReference;
+import java.util.concurrent.atomic.AtomicLong;
+
+import io.micrometer.core.instrument.MeterRegistry;
+import io.micrometer.core.instrument.simple.SimpleMeterRegistry;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
+
+/**
+ * Micrometer holds the state object of a gauge through a weak reference, so the remaining-signatures supplier has to be
+ * kept reachable by this class or the gauge silently degrades to NaN.
+ */
+class PQCMicrometerMetricsTest {
+
+    @Test
+    void theStatefulGaugeKeepsReportingAfterTheSupplierBecomesUnreachable() {
+        MeterRegistry registry = new SimpleMeterRegistry();
+        PQCMicrometerMetrics metrics = new PQCMicrometerMetrics(registry);
+
+        AtomicLong remaining = new AtomicLong(42);
+        // the lambda is reachable only through the metrics instance from here on
+        metrics.registerStatefulKeyGauge("LMS", remaining::get);
+
+        forceGc();
+
+        assertEquals(42.0,
+                registry.get(PQCMicrometerMetrics.METRIC_STATEFUL_REMAINING).tag("algorithm", "LMS").gauge().value(),
+                "the gauge must still read the supplier after a collection");
+
+        remaining.set(7);
+        assertEquals(7.0,
+                registry.get(PQCMicrometerMetrics.METRIC_STATEFUL_REMAINING).tag("algorithm", "LMS").gauge().value(),
+                "the gauge must track the live value, not a snapshot");
+    }
+
+    @Test
+    void registeringASecondGaugeDoesNotOrphanTheFirst() {
+        MeterRegistry registry = new SimpleMeterRegistry();
+        PQCMicrometerMetrics metrics = new PQCMicrometerMetrics(registry);
+
+        metrics.registerStatefulKeyGauge("LMS", () -> 10);
+        metrics.registerStatefulKeyGauge("XMSS", () -> 20);
+
+        assertEquals(10.0,
+                registry.get(PQCMicrometerMetrics.METRIC_STATEFUL_REMAINING).tag("algorithm", "LMS").gauge().value());
+        assertEquals(20.0,
+                registry.get(PQCMicrometerMetrics.METRIC_STATEFUL_REMAINING).tag("algorithm", "XMSS").gauge().value());
+
+        metrics.close();
+
+        assertNull(registry.find(PQCMicrometerMetrics.METRIC_STATEFUL_REMAINING).tag("algorithm", "LMS").gauge(),
+                "close() must remove every gauge it registered, not only the last one");
+        assertNull(registry.find(PQCMicrometerMetrics.METRIC_STATEFUL_REMAINING).tag("algorithm", "XMSS").gauge());
+    }
+
+    @Test
+    void operationCountersAreRecordedAndRemovedOnClose() {
+        MeterRegistry registry = new SimpleMeterRegistry();
+        PQCMicrometerMetrics metrics = new PQCMicrometerMetrics(registry);
+
+        metrics.recordOperation("sign", "MLDSA", true);
+        metrics.recordOperation("sign", "MLDSA", true);
+        metrics.recordOperation("sign", "MLDSA", false);
+
+        assertEquals(2.0, registry.get(PQCMicrometerMetrics.METRIC_OPERATIONS)
+                .tag("operation", "sign").tag("algorithm", "MLDSA").tag("outcome", "success").counter().count());
+        assertEquals(1.0, registry.get(PQCMicrometerMetrics.METRIC_OPERATIONS)
+                .tag("operation", "sign").tag("algorithm", "MLDSA").tag("outcome", "failure").counter().count());
+
+        metrics.close();
+
+        assertNull(registry.find(PQCMicrometerMetrics.METRIC_OPERATIONS).counter());
+    }
+
+    @Test
+    void noMeterRegistryYieldsTheNoopImplementation() {
+        assertNotNull(PQCMetrics.NOOP);
+        // the no-op must tolerate every call without a registry behind it
+        PQCMetrics.NOOP.recordOperation("sign", "MLDSA", true);
+        PQCMetrics.NOOP.registerStatefulKeyGauge("LMS", () -> 1);
+        PQCMetrics.NOOP.close();
+        assertFalse(PQCMetrics.NOOP instanceof PQCMicrometerMetrics);
+    }
+
+    /**
+     * Collects until a canary weak reference is actually cleared, so the assertion that follows is about the gauge
+     * rather than about whether a collection happened to run.
+     */
+    private static void forceGc() {
+        WeakReference<Object> canary = new WeakReference<>(new Object());
+        for (int i = 0; i < 100 && canary.get() != null; i++) {
+            System.gc();
+        }
+        assertNull(canary.get(), "no garbage collection was observed, the test below would prove nothing");

Review Comment:
   Nit: on a JVM started with `-XX:+DisableExplicitGC`, `System.gc()` does nothing and this fails the test, though nothing is wrong with the code. `assumeTrue(canary.get() == null, ...)` (from `org.junit.jupiter.api.Assumptions`) would skip the test there instead.



##########
components/camel-pqc/src/test/java/org/apache/camel/component/pqc/metrics/PQCMicrometerMetricsTest.java:
##########
@@ -0,0 +1,118 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.pqc.metrics;
+
+import java.lang.ref.WeakReference;
+import java.util.concurrent.atomic.AtomicLong;
+
+import io.micrometer.core.instrument.MeterRegistry;
+import io.micrometer.core.instrument.simple.SimpleMeterRegistry;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
+
+/**
+ * Micrometer holds the state object of a gauge through a weak reference, so the remaining-signatures supplier has to be
+ * kept reachable by this class or the gauge silently degrades to NaN.
+ */
+class PQCMicrometerMetricsTest {
+
+    @Test
+    void theStatefulGaugeKeepsReportingAfterTheSupplierBecomesUnreachable() {
+        MeterRegistry registry = new SimpleMeterRegistry();
+        PQCMicrometerMetrics metrics = new PQCMicrometerMetrics(registry);
+
+        AtomicLong remaining = new AtomicLong(42);
+        // the lambda is reachable only through the metrics instance from here on
+        metrics.registerStatefulKeyGauge("LMS", remaining::get);
+
+        forceGc();
+
+        assertEquals(42.0,
+                registry.get(PQCMicrometerMetrics.METRIC_STATEFUL_REMAINING).tag("algorithm", "LMS").gauge().value(),
+                "the gauge must still read the supplier after a collection");
+
+        remaining.set(7);
+        assertEquals(7.0,
+                registry.get(PQCMicrometerMetrics.METRIC_STATEFUL_REMAINING).tag("algorithm", "LMS").gauge().value(),
+                "the gauge must track the live value, not a snapshot");
+    }
+
+    @Test
+    void registeringASecondGaugeDoesNotOrphanTheFirst() {
+        MeterRegistry registry = new SimpleMeterRegistry();
+        PQCMicrometerMetrics metrics = new PQCMicrometerMetrics(registry);
+
+        metrics.registerStatefulKeyGauge("LMS", () -> 10);
+        metrics.registerStatefulKeyGauge("XMSS", () -> 20);
+
+        assertEquals(10.0,
+                registry.get(PQCMicrometerMetrics.METRIC_STATEFUL_REMAINING).tag("algorithm", "LMS").gauge().value());
+        assertEquals(20.0,
+                registry.get(PQCMicrometerMetrics.METRIC_STATEFUL_REMAINING).tag("algorithm", "XMSS").gauge().value());
+
+        metrics.close();
+
+        assertNull(registry.find(PQCMicrometerMetrics.METRIC_STATEFUL_REMAINING).tag("algorithm", "LMS").gauge(),
+                "close() must remove every gauge it registered, not only the last one");
+        assertNull(registry.find(PQCMicrometerMetrics.METRIC_STATEFUL_REMAINING).tag("algorithm", "XMSS").gauge());
+    }
+
+    @Test
+    void operationCountersAreRecordedAndRemovedOnClose() {
+        MeterRegistry registry = new SimpleMeterRegistry();
+        PQCMicrometerMetrics metrics = new PQCMicrometerMetrics(registry);
+
+        metrics.recordOperation("sign", "MLDSA", true);
+        metrics.recordOperation("sign", "MLDSA", true);
+        metrics.recordOperation("sign", "MLDSA", false);
+
+        assertEquals(2.0, registry.get(PQCMicrometerMetrics.METRIC_OPERATIONS)
+                .tag("operation", "sign").tag("algorithm", "MLDSA").tag("outcome", "success").counter().count());
+        assertEquals(1.0, registry.get(PQCMicrometerMetrics.METRIC_OPERATIONS)
+                .tag("operation", "sign").tag("algorithm", "MLDSA").tag("outcome", "failure").counter().count());
+
+        metrics.close();
+
+        assertNull(registry.find(PQCMicrometerMetrics.METRIC_OPERATIONS).counter());
+    }
+
+    @Test
+    void noMeterRegistryYieldsTheNoopImplementation() {

Review Comment:
   Nit: the name says "no meter registry yields the no-op", but the test never calls `PQCMicrometerMetrics.create(...)`. It only calls the no-op directly. Either call `create` with a `CamelContext` whose registry has no `MeterRegistry` and assert it returns `PQCMetrics.NOOP`, or rename the test to what it checks.



-- 
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: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] CAMEL-25804: camel-pqc - keep the stateful key gauge supplier reachable [camel]

Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #28102:
URL: https://github.com/apache/camel/pull/28102#issuecomment-6264953387

   :star2: Thank you for your contribution to the Apache Camel project! :star2:
     :robot: CI automation will test this PR automatically.
   
     :camel: Apache Camel Committers, please review the following items:
   
     * First-time contributors **require MANUAL approval** for the GitHub Actions to run
     * You can use the command `/component-test (camel-)component-name1 (camel-)component-name2..` to request a test from the test bot although they are normally detected and executed by CI.
     * You can label PRs using `skip-tests` and `test-dependents` to fine-tune the checks executed by this PR.
     * Build and test logs are available in the summary page. **Only** [Apache Camel committers](https://camel.apache.org/community/team/#committers) have access to the summary.
     
     :warning: Be careful when sharing logs. Review their contents before sharing them publicly.


-- 
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: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] CAMEL-25804: camel-pqc - keep the stateful key gauge supplier reachable [camel]

Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #28102:
URL: https://github.com/apache/camel/pull/28102#issuecomment-6267963006

   <!-- ci-tested-modules -->
   :test_tube: **CI tested the following changed modules:**
   
   - `components/camel-pqc`
   
   ---
   
   <details><summary>:microscope: Scalpel shadow comparison — Scalpel: 8 of 706 tested, 27 compile-only — current: 8 all tested</summary>
   
   [Maveniverse Scalpel](https://github.com/maveniverse/scalpel) detected **8 affected modules** (current approach: 8).
   
   **Skip-tests mode would test 8 modules** (1 direct + 7 downstream), **skip tests for 27** (generated code, meta-modules)
   
   <details><summary>Modules Scalpel would test (8)</summary>
   
   - `camel-jbang-mcp` ← downstream of org.apache.camel:camel-catalog
   - `camel-jbang-plugin-mcp` ← downstream of org.apache.camel:camel-jbang-core
   - `camel-jbang-plugin-tui` ← downstream of org.apache.camel:camel-catalog
   - `camel-jbang-plugin-validate` ← downstream of org.apache.camel:camel-yaml-dsl-validator
   - `camel-launcher-container` ← downstream of org.apache.camel:camel-launcher
   - `camel-pqc` ← components/camel-pqc/src/main/java/org/apache/camel/component/pqc/metrics/PQCMicrometerMetrics.java, components/camel-pqc/src/test/java/org/apache/camel/component/pqc/metrics/PQCMicrometerMetricsTest.java
   - `camel-yaml-dsl-validator` ← downstream of org.apache.camel:camel-catalog
   - `camel-yaml-dsl-validator-maven-plugin` ← downstream of org.apache.camel:camel-yaml-dsl-validator
   
   </details>
   
   <details><summary>Modules with tests skipped (27)</summary>
   
   - `apache-camel`
   - `camel-allcomponents`
   - `camel-catalog`
   - `camel-catalog-console`
   - `camel-catalog-maven`
   - `camel-catalog-suggest`
   - `camel-componentdsl`
   - `camel-endpointdsl`
   - `camel-endpointdsl-support`
   - `camel-itest`
   - `camel-jbang-core`
   - `camel-jbang-it`
   - `camel-jbang-main`
   - `camel-jbang-plugin-edit`
   - `camel-jbang-plugin-generate`
   - `camel-jbang-plugin-kubernetes`
   - `camel-jbang-plugin-test`
   - `camel-kamelet-main`
   - `camel-launcher`
   - `camel-report-maven-plugin`
   - `camel-route-parser`
   - `camel-yaml-dsl`
   - `camel-yaml-dsl-deserializers`
   - `camel-yaml-dsl-maven-plugin`
   - `coverage`
   - `docs`
   - `dummy-component`
   
   </details>
   
   > :information_source: Shadow mode — Scalpel observes but does not affect test execution. [Learn more](https://github.com/maveniverse/scalpel)
   
   </details>
   
   <details><summary>All tested modules (35 modules, 5m 39s total)</summary>
   
   **Total reactor time:** 5m 39s
   
   | Module | Duration | Status |
   | --- | --- | --- |
   | Camel :: Launcher | 50.4s | SUCCESS |
   | Camel :: JBang :: MCP | 43.9s | SUCCESS |
   | Camel :: JBang :: Plugin :: Validate | 27.9s | SUCCESS |
   | Camel :: YAML DSL :: Validator | 25.5s | SUCCESS |
   | Camel :: YAML DSL | 24.9s | SUCCESS |
   | Camel :: Catalog :: Camel Catalog | 24.3s | SUCCESS |
   | Camel :: Component DSL | 19.2s | SUCCESS |
   | Camel :: Kamelet Main | 17.3s | SUCCESS |
   | Camel :: JBang :: Plugin :: Testing | 16.9s | SUCCESS |
   | Camel :: Docs | 15.8s | SUCCESS |
   | Camel :: JBang :: Plugin :: Kubernetes | 14.9s | SUCCESS |
   | Camel :: YAML DSL :: Deserializers | 7.8s | SUCCESS |
   | Camel :: Catalog :: Camel Route Parser | 7.6s | SUCCESS |
   | Camel :: Assembly | 7.4s | SUCCESS |
   | Camel :: Catalog :: Camel Report Maven Plugin | 7.1s | SUCCESS |
   | Camel :: All Components Sync point | 4.9s | SUCCESS |
   | Camel :: YAML DSL :: Validator Maven Plugin | 4.5s | SUCCESS |
   | Camel :: Catalog :: Maven | 3.4s | SUCCESS |
   | Camel :: YAML DSL :: Maven Plugins | 3.1s | SUCCESS |
   | Camel :: Catalog :: Suggest (deprecated) | 2.6s | SUCCESS |
   | Camel :: JBang :: Plugin :: Edit | 1.6s | SUCCESS |
   | Camel :: Coverage | 1.3s | SUCCESS |
   | Camel :: JBang :: Integration tests | 1.2s | SUCCESS |
   | Camel :: Catalog :: Dummy Component | 1.1s | SUCCESS |
   | Camel :: JBang :: Plugin :: Generate | 1.1s | SUCCESS |
   | Camel :: Endpoint DSL :: Support | 0.9s | SUCCESS |
   | Camel :: Catalog :: Console | 0.8s | SUCCESS |
   | Camel :: JBang :: Plugin :: MCP | 0.8s | SUCCESS |
   | Camel :: Launcher :: Container | 0.8s | SUCCESS |
   | Camel :: JBang :: Main | 0.7s | SUCCESS |
   | Camel :: Endpoint DSL | n/a |  |
   | Camel :: Integration Tests | n/a |  |
   | Camel :: JBang :: Core | n/a |  |
   | Camel :: JBang :: Plugin :: TUI | n/a |  |
   | Camel :: PQC | n/a |  |
   
   **Top 20 slowest modules:**
   - `Camel :: Launcher` (50.4s)
   - `Camel :: JBang :: MCP` (43.9s)
   - `Camel :: JBang :: Plugin :: Validate` (27.9s)
   - `Camel :: YAML DSL :: Validator` (25.5s)
   - `Camel :: YAML DSL` (24.9s)
   - `Camel :: Catalog :: Camel Catalog` (24.3s)
   - `Camel :: Component DSL` (19.2s)
   - `Camel :: Kamelet Main` (17.3s)
   - `Camel :: JBang :: Plugin :: Testing` (16.9s)
   - `Camel :: Docs` (15.8s)
   - `Camel :: JBang :: Plugin :: Kubernetes` (14.9s)
   - `Camel :: YAML DSL :: Deserializers` (7.8s)
   - `Camel :: Catalog :: Camel Route Parser` (7.6s)
   - `Camel :: Assembly` (7.4s)
   - `Camel :: Catalog :: Camel Report Maven Plugin` (7.1s)
   - `Camel :: All Components Sync point` (4.9s)
   - `Camel :: YAML DSL :: Validator Maven Plugin` (4.5s)
   - `Camel :: Catalog :: Maven` (3.4s)
   - `Camel :: YAML DSL :: Maven Plugins` (3.1s)
   - `Camel :: Catalog :: Suggest (deprecated)` (2.6s)
   
   </details>
   
   ---
   :gear: [View full build and test results](https://github.com/apache/camel/actions/runs/39235059127)


-- 
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: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] CAMEL-25804: camel-pqc - keep the stateful key gauge supplier reachable [camel]

Posted by "davsclaus (via GitHub)" <gi...@apache.org>.
davsclaus merged PR #28102:
URL: https://github.com/apache/camel/pull/28102


-- 
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: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org