You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When a rule is flagged as cacheable (which is desirable for performance reasons when not machting on values themselves), then the first collection provides the provided HELP message for the collected metrics of the rule, but any additional collection looses this help message and falls back to the regular JMX bean description help message.
Unit test exhibiting the issue:
index 7952fd5..bb0593a 100644
--- a/collector/src/test/java/io/prometheus/jmx/JmxCollectorTest.java+++ b/collector/src/test/java/io/prometheus/jmx/JmxCollectorTest.java@@ -2,11 +2,15 @@ package io.prometheus.jmx;
import io.prometheus.client.Collector;
import io.prometheus.client.CollectorRegistry;
+import io.prometheus.client.Collector.MetricFamilySamples;+
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import java.lang.management.ManagementFactory;
+import java.util.List;+
import javax.management.MBeanServer;
import static org.junit.Assert.assertEquals;
@@ -284,4 +288,14 @@ public class JmxCollectorTest {
assertTrue(registry.getSampleValue("jmx_scrape_cached_beans", new String[]{}, new String[]{}) > 0);
assertEquals(4.0, registry.getSampleValue("foo", new String[]{}, new String[]{}), .001);
}
++ @Test+ public void testCachedBeansEnabledRetainsHelpAcrossCollections() throws Exception {+ JmxCollector jc = new JmxCollector("\n---\nrules:\n- pattern: `.*`\n name: foo\n value: 1\n valueFactor: 4\n cache: true\n help: help message".replace('`','"'))+ .register(registry);+ List<MetricFamilySamples> samples = jc.collect();+ assertEquals("help message", samples.get(0).help);+ samples = jc.collect();+ assertEquals("help message", samples.get(0).help);+ }
}
The second assertion fails:
org.junit.ComparisonFailure: expected:<[help message]> but was:<[BootClassPathSupported (java.lang<type=Runtime><>BootClassPathSupported)]>
The text was updated successfully, but these errors were encountered:
davoustp
changed the title
Cached rules does not retain the help message across collections
Cached rules does not retain help message across collections
Jun 14, 2021
When a rule is flagged as cacheable (which is desirable for performance reasons when not machting on values themselves), then the first collection provides the provided HELP message for the collected metrics of the rule, but any additional collection looses this help message and falls back to the regular JMX bean description help message.
Unit test exhibiting the issue:
The second assertion fails:
The text was updated successfully, but these errors were encountered: