-
Notifications
You must be signed in to change notification settings - Fork 807
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make JvmMetrics.register idempotent with the default registry (#987)
* Make JvmMetrics.register idempotent with the default registry Signed-off-by: Mickael Maison <[email protected]> * Make JvmMetrics.register() methods idempotent Signed-off-by: Mickael Maison <[email protected]> --------- Signed-off-by: Mickael Maison <[email protected]>
- Loading branch information
Showing
2 changed files
with
40 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
...mentation-jvm/src/test/java/io/prometheus/metrics/instrumentation/jvm/JvmMetricsTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package io.prometheus.metrics.instrumentation.jvm; | ||
|
||
import io.prometheus.metrics.model.registry.PrometheusRegistry; | ||
import org.junit.Test; | ||
|
||
import static org.junit.Assert.assertEquals; | ||
import static org.junit.Assert.assertTrue; | ||
|
||
public class JvmMetricsTest { | ||
|
||
@Test | ||
public void testRegisterIdempotent() { | ||
PrometheusRegistry registry = new PrometheusRegistry(); | ||
assertEquals(0, registry.scrape().size()); | ||
JvmMetrics.builder().register(registry); | ||
assertTrue(registry.scrape().size() > 0); | ||
JvmMetrics.builder().register(registry); | ||
} | ||
} |