ensure sigar metrics are reusable - just a small protection for weird systems
authorRomain Manni-Bucau <rmannibucau@gmail.com>
Tue, 8 Jan 2019 17:36:59 +0000 (18:36 +0100)
committerRomain Manni-Bucau <rmannibucau@gmail.com>
Tue, 8 Jan 2019 17:36:59 +0000 (18:36 +0100)
geronimo-metrics-extensions/geronimo-metrics-extension-common/src/main/java/org/apache/geronimo/microprofile/metrics/extension/common/MicroprofileMetricsAdapter.java

index f9259d8..986aa7a 100644 (file)
@@ -32,9 +32,13 @@ public class MicroprofileMetricsAdapter {
     }
 
     public Consumer<Definition> registrer() {
-        return def -> registry.register(
-                new Metadata(def.getName(), def.getDisplayName(), def.getDescription(), GAUGE, def.getUnit()),
-                (Gauge<Double>) () -> def.getEvaluator().getAsDouble());
+        return def -> {
+            final Metadata metadata = new Metadata(def.getName(), def.getDisplayName(), def.getDescription(), GAUGE,
+                    def.getUnit());
+            metadata.setReusable(true);
+            registry.register(metadata,
+                    (Gauge<Double>) () -> def.getEvaluator().getAsDouble());
+        };
     }
 
     public Consumer<Definition> unregistrer() {