diff --git a/jmx-scraper/README.md b/jmx-scraper/README.md index 18d73de10..31fd8024d 100644 --- a/jmx-scraper/README.md +++ b/jmx-scraper/README.md @@ -40,6 +40,7 @@ For example the `otel.jmx.service.url` option can be set with the `OTEL_JMX_SERV |--------------------------------|---------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------| | `otel.jmx.service.url` | - | mandatory JMX URL to connect to the remote JVM | | `otel.jmx.target.system` | - | comma-separated list of systems to monitor, mandatory unless `otel.jmx.config` is set | +| `otel.jmx.target.source` | `auto` | source of metrics definitions to use for `otel.jmx.target.system`, supported values are `auto`, `instrumentation` and `legacy` | | `otel.jmx.config` | empty | comma-separated list of paths to custom YAML metrics definition, mandatory when `otel.jmx.target.system` is not set | | `otel.jmx.username` | - | user name for JMX connection, mandatory when JMX authentication is set on target JVM with`com.sun.management.jmxremote.authenticate=true` | | `otel.jmx.password` | - | password for JMX connection, mandatory when JMX authentication is set on target JVM with `com.sun.management.jmxremote.authenticate=true` | @@ -55,22 +56,34 @@ When both `otel.jmx.target.system` and `otel.jmx.config` configuration options a If there is a need to override existing ready-to-use metrics or to keep control on the metrics definitions, using a custom YAML definition with `otel.jmx.config` is the recommended option. -Supported values for `otel.jmx.target.system`: - -| `otel.jmx.target.system` | description | -|--------------------------|-----------------------| -| `activemq` | Apache ActiveMQ | -| `cassandra` | Apache Cassandra | -| `hbase` | Apache HBase | -| `hadoop` | Apache Hadoop | -| `jetty` | Eclipse Jetty | -| `jvm` | JVM runtime metrics | -| `kafka` | Apache Kafka | -| `kafka-consumer` | Apache Kafka consumer | -| `kafka-producer` | Apache Kafka producer | -| `solr` | Apache Solr | -| `tomcat` | Apache Tomcat | -| `wildfly` | Wildfly | +Supported values for `otel.jmx.target.system` and support for `otel.jmx.target.source` and links to the metrics definitions: + +| `otel.jmx.target.system` | description | `legacy` | `instrumentation` | +|--------------------------|-----------------------|-----------------------------------------------------------------|-------------------| +| `activemq` | Apache ActiveMQ | [`activemq.yaml`](src/main/resources/activemq.yaml) | | +| `cassandra` | Apache Cassandra | [`cassandra.yaml`](src/main/resources/cassandra.yaml) | | +| `hbase` | Apache HBase | [`hbase.yaml`](src/main/resources/hbase.yaml) | | +| `hadoop` | Apache Hadoop | [`hadoop.yaml`](src/main/resources/hadoop.yaml) | | +| `jetty` | Eclipse Jetty | [`jetty.yaml`](src/main/resources/jetty.yaml) | | +| `jvm` | JVM runtime metrics | [`jvm.yaml`](src/main/resources/jvm.yaml) | | +| `kafka` | Apache Kafka | [`kafka.yaml`](src/main/resources/kafka.yaml) | | +| `kafka-consumer` | Apache Kafka consumer | [`kafka-consumer.yaml`](src/main/resources/kafka-consumer.yaml) | | +| `kafka-producer` | Apache Kafka producer | [`kafka-producer.yaml`](src/main/resources/kafka-producer.yaml) | | +| `solr` | Apache Solr | [`solr.yaml`](src/main/resources/solr.yaml) | | +| `tomcat` | Apache Tomcat | [`tomcat.yaml`](src/main/resources/tomcat.yaml) | | +| `wildfly` | Wildfly | [`wildfly.yaml`](src/main/resources/wildfly.yaml) | | + +The source of metrics definitions is controlled by `otel.jmx.target.source`: + +- `auto` (default) : metrics definitions from `instrumentation` with fallback on `legacy` when not available. +- `legacy` : metrics definitions embedded in jmx-scraper, almost equivalent to [JMX Gatherer](https://github.com/open-telemetry/opentelemetry-java-contrib/tree/main/jmx-metrics). +- `instrumentation` : metrics definitions embedded in [instrumentation/jmx-metrics](https://github.com/open-telemetry/opentelemetry-java-instrumentation/tree/main/instrumentation/jmx-metrics/library) library + +Setting the value of `otel.jmx.target.source` allows to fit the following use-cases: + +- `auto` will ensure that the latest metrics definitions in instrumentation (reference) is being used when available with a fallback on `legacy` otherwise. Metrics definitions will thus be updated whenever the dependency on instrumentation is updated. +- `legacy` allows to keep using definitions that are very close to JMX Gatherer, this is the recommended option if preserving compatibility is required. Those definitions are in maintenance and are unlikely to evolve over time. +- `instrumentation` forces using metrics definitions from instrumentation, hence only the reference. Metrics definitions and supported values of `otel.jmx.target.system` will be updated whenever the dependency on instrumentation is updated. The following SDK configuration options are also relevant diff --git a/jmx-scraper/src/integrationTest/java/io/opentelemetry/contrib/jmxscraper/JmxScraperContainer.java b/jmx-scraper/src/integrationTest/java/io/opentelemetry/contrib/jmxscraper/JmxScraperContainer.java index 12e1dc487..29dedd7b6 100644 --- a/jmx-scraper/src/integrationTest/java/io/opentelemetry/contrib/jmxscraper/JmxScraperContainer.java +++ b/jmx-scraper/src/integrationTest/java/io/opentelemetry/contrib/jmxscraper/JmxScraperContainer.java @@ -26,6 +26,7 @@ public class JmxScraperContainer extends GenericContainer { private final String endpoint; private final Set targetSystems; + private String targetSystemSource; private String serviceUrl; private final Set customYamlFiles; private String user; @@ -46,6 +47,7 @@ public JmxScraperContainer(String otlpEndpoint, String baseImage) { this.endpoint = otlpEndpoint; this.targetSystems = new HashSet<>(); + this.targetSystemSource = "auto"; this.customYamlFiles = new HashSet<>(); this.extraJars = new ArrayList<>(); } @@ -62,6 +64,18 @@ public JmxScraperContainer withTargetSystem(String targetSystem) { return this; } + /** + * Sets the target system source + * + * @param source target system source, valid values are "auto", "instrumentation" and "legacy" + * @return this + */ + @CanIgnoreReturnValue + public JmxScraperContainer withTargetSystemSource(String source) { + this.targetSystemSource = source; + return this; + } + /** * Set connection to a standard JMX service URL * @@ -192,6 +206,7 @@ public void start() { if (!targetSystems.isEmpty()) { arguments.add("-Dotel.jmx.target.system=" + String.join(",", targetSystems)); + arguments.add("-Dotel.jmx.target.source=" + targetSystemSource); } if (serviceUrl == null) { diff --git a/jmx-scraper/src/integrationTest/java/io/opentelemetry/contrib/jmxscraper/target_systems/JvmIntegrationTest.java b/jmx-scraper/src/integrationTest/java/io/opentelemetry/contrib/jmxscraper/target_systems/JvmIntegrationTest.java index e29021a93..6c4069638 100644 --- a/jmx-scraper/src/integrationTest/java/io/opentelemetry/contrib/jmxscraper/target_systems/JvmIntegrationTest.java +++ b/jmx-scraper/src/integrationTest/java/io/opentelemetry/contrib/jmxscraper/target_systems/JvmIntegrationTest.java @@ -32,6 +32,12 @@ protected JmxScraperContainer customizeScraperContainer( JmxScraperContainer scraper, GenericContainer target, Path tempDir) { return scraper .withTargetSystem("jvm") + // TODO when JVM metrics will be added to instrumentation, the default "auto" source + // means that the definitions in instrumentation will be used, and thus this test will fail + // due to metrics differences, adding an explicit "legacy" source is required to continue + // testing the JVM metrics defined in this project. + // https://github.com/open-telemetry/opentelemetry-java-instrumentation/pull/13392 + // .withTargetSystem("legacy") // also testing custom yaml .withCustomYaml("custom-metrics.yaml"); } diff --git a/jmx-scraper/src/main/java/io/opentelemetry/contrib/jmxscraper/JmxScraper.java b/jmx-scraper/src/main/java/io/opentelemetry/contrib/jmxscraper/JmxScraper.java index cf6250bab..8bf9f46ce 100644 --- a/jmx-scraper/src/main/java/io/opentelemetry/contrib/jmxscraper/JmxScraper.java +++ b/jmx-scraper/src/main/java/io/opentelemetry/contrib/jmxscraper/JmxScraper.java @@ -228,7 +228,11 @@ private void start() throws IOException { private static MetricConfiguration getMetricConfig(JmxScraperConfig scraperConfig) { MetricConfiguration config = new MetricConfiguration(); for (String system : scraperConfig.getTargetSystems()) { - addRulesForSystem(system, config); + try (InputStream yaml = scraperConfig.getTargetSystemYaml(system)) { + RuleParser.get().addMetricDefsTo(config, yaml, system); + } catch (IOException e) { + throw new IllegalStateException("Error while loading rules for system " + system, e); + } } for (String file : scraperConfig.getJmxConfig()) { addRulesFromFile(file, config); @@ -236,20 +240,6 @@ private static MetricConfiguration getMetricConfig(JmxScraperConfig scraperConfi return config; } - private static void addRulesForSystem(String system, MetricConfiguration conf) { - String yamlResource = system + ".yaml"; - try (InputStream inputStream = - JmxScraper.class.getClassLoader().getResourceAsStream(yamlResource)) { - if (inputStream != null) { - RuleParser.get().addMetricDefsTo(conf, inputStream, system); - } else { - throw new IllegalArgumentException("No support for system " + system); - } - } catch (Exception e) { - throw new IllegalStateException("Error while loading rules for system " + system, e); - } - } - private static void addRulesFromFile(String file, MetricConfiguration conf) { Path path = Paths.get(file); if (!Files.isReadable(path)) { diff --git a/jmx-scraper/src/main/java/io/opentelemetry/contrib/jmxscraper/config/JmxScraperConfig.java b/jmx-scraper/src/main/java/io/opentelemetry/contrib/jmxscraper/config/JmxScraperConfig.java index 1954a9959..09a97eb83 100644 --- a/jmx-scraper/src/main/java/io/opentelemetry/contrib/jmxscraper/config/JmxScraperConfig.java +++ b/jmx-scraper/src/main/java/io/opentelemetry/contrib/jmxscraper/config/JmxScraperConfig.java @@ -7,12 +7,13 @@ import io.opentelemetry.sdk.autoconfigure.spi.ConfigProperties; import io.opentelemetry.sdk.autoconfigure.spi.ConfigurationException; +import java.io.InputStream; import java.time.Duration; import java.util.ArrayList; -import java.util.Arrays; import java.util.Collections; import java.util.HashSet; import java.util.List; +import java.util.Locale; import java.util.Set; import java.util.logging.Logger; import javax.annotation.Nullable; @@ -37,37 +38,23 @@ public class JmxScraperConfig { static final String JMX_CONFIG_LEGACY = "otel.jmx.custom.scraping.config"; static final String JMX_TARGET_SYSTEM = "otel.jmx.target.system"; + static final String JMX_TARGET_SOURCE = "otel.jmx.target.source"; static final String JMX_USERNAME = "otel.jmx.username"; static final String JMX_PASSWORD = "otel.jmx.password"; - // TODO: document those when they will be supported static final String JMX_REGISTRY_SSL = "otel.jmx.remote.registry.ssl"; static final String JMX_REMOTE_PROFILE = "otel.jmx.remote.profile"; static final String JMX_REALM = "otel.jmx.realm"; - private static final List AVAILABLE_TARGET_SYSTEMS = - Collections.unmodifiableList( - Arrays.asList( - "activemq", - "cassandra", - "hbase", - "hadoop", - "jetty", - "jvm", - "kafka", - "kafka-consumer", - "kafka-producer", - "solr", - "tomcat", - "wildfly")); - private String serviceUrl = ""; private List jmxConfig = Collections.emptyList(); private Set targetSystems = Collections.emptySet(); + private TargetSystemSource targetSystemSource = TargetSystemSource.AUTO; + private Duration samplingInterval = Duration.ofMinutes(1); @Nullable private String username; @@ -79,6 +66,20 @@ public class JmxScraperConfig { @Nullable private String remoteProfile; private boolean registrySsl; + public enum TargetSystemSource { + AUTO, + INSTRUMENTATION, + LEGACY; + + static TargetSystemSource fromString(String source) { + try { + return TargetSystemSource.valueOf(source.toUpperCase(Locale.ROOT)); + } catch (IllegalArgumentException e) { + throw new IllegalArgumentException("Invalid target system source: " + source, e); + } + } + } + private JmxScraperConfig() {} public String getServiceUrl() { @@ -93,6 +94,57 @@ public Set getTargetSystems() { return targetSystems; } + /** + * Resolves the target system yaml from configuration + * + * @param system target system + * @return input stream on target system yaml definitions + * @throws ConfigurationException when no yaml for system is available + */ + public InputStream getTargetSystemYaml(String system) { + InputStream yaml; + switch (targetSystemSource) { + case LEGACY: + yaml = getTargetSystemYaml(system, TargetSystemSource.LEGACY); + break; + case INSTRUMENTATION: + yaml = getTargetSystemYaml(system, TargetSystemSource.INSTRUMENTATION); + break; + case AUTO: + yaml = getTargetSystemYaml(system, TargetSystemSource.INSTRUMENTATION); + if (yaml == null) { + yaml = getTargetSystemYaml(system, TargetSystemSource.LEGACY); + } + break; + default: + throw new IllegalStateException("unsupported target system source: " + targetSystemSource); + } + + if (yaml == null) { + throw new ConfigurationException( + "unsupported target system: '" + system + "', source: " + targetSystemSource); + } + return yaml; + } + + @Nullable + private static InputStream getTargetSystemYaml(String system, TargetSystemSource source) { + String path; + switch (source) { + case LEGACY: + path = String.format("%s.yaml", system); + break; + case INSTRUMENTATION: + path = String.format("jmx/rules/%s.yaml", system); + break; + case AUTO: + default: + throw new IllegalArgumentException("invalid source" + source); + } + + return JmxScraperConfig.class.getClassLoader().getResourceAsStream(path); + } + public Duration getSamplingInterval() { return samplingInterval; } @@ -164,12 +216,6 @@ public static JmxScraperConfig fromConfig(ConfigProperties config) { throw new ConfigurationException( "at least one of '" + JMX_TARGET_SYSTEM + "' or '" + JMX_CONFIG + "' must be set"); } - targetSystem.forEach( - s -> { - if (!AVAILABLE_TARGET_SYSTEMS.contains(s)) { - throw new ConfigurationException("unsupported target system: '" + s + "'"); - } - }); scraperConfig.jmxConfig = Collections.unmodifiableList(jmxConfig); scraperConfig.targetSystems = Collections.unmodifiableSet(new HashSet<>(targetSystem)); @@ -180,6 +226,13 @@ public static JmxScraperConfig fromConfig(ConfigProperties config) { scraperConfig.realm = config.getString("otel.jmx.realm"); scraperConfig.registrySsl = config.getBoolean("otel.jmx.remote.registry.ssl", false); + // checks target system is supported by resolving the yaml resource, throws exception on + // missing/error + scraperConfig.targetSystems.forEach(scraperConfig::getTargetSystemYaml); + + String source = config.getString(JMX_TARGET_SOURCE, TargetSystemSource.AUTO.name()); + scraperConfig.targetSystemSource = TargetSystemSource.fromString(source); + return scraperConfig; } } diff --git a/jmx-scraper/src/test/java/io/opentelemetry/contrib/jmxscraper/config/JmxScraperConfigTest.java b/jmx-scraper/src/test/java/io/opentelemetry/contrib/jmxscraper/config/JmxScraperConfigTest.java index 4b6188e53..82b776bbf 100644 --- a/jmx-scraper/src/test/java/io/opentelemetry/contrib/jmxscraper/config/JmxScraperConfigTest.java +++ b/jmx-scraper/src/test/java/io/opentelemetry/contrib/jmxscraper/config/JmxScraperConfigTest.java @@ -12,6 +12,7 @@ import static io.opentelemetry.contrib.jmxscraper.config.JmxScraperConfig.JMX_REGISTRY_SSL; import static io.opentelemetry.contrib.jmxscraper.config.JmxScraperConfig.JMX_REMOTE_PROFILE; import static io.opentelemetry.contrib.jmxscraper.config.JmxScraperConfig.JMX_SERVICE_URL; +import static io.opentelemetry.contrib.jmxscraper.config.JmxScraperConfig.JMX_TARGET_SOURCE; import static io.opentelemetry.contrib.jmxscraper.config.JmxScraperConfig.JMX_TARGET_SYSTEM; import static io.opentelemetry.contrib.jmxscraper.config.JmxScraperConfig.JMX_USERNAME; import static io.opentelemetry.contrib.jmxscraper.config.JmxScraperConfig.fromConfig; @@ -19,11 +20,14 @@ import static org.assertj.core.api.Assertions.assertThatThrownBy; import io.opentelemetry.sdk.autoconfigure.spi.ConfigurationException; +import java.io.InputStream; import java.time.Duration; +import java.util.Locale; import java.util.Properties; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Test; import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.EnumSource; import org.junit.jupiter.params.provider.ValueSource; class JmxScraperConfigTest { @@ -138,11 +142,13 @@ void shouldFailValidation_missingConfigPathAndTargetSystem() { .hasMessage("at least one of 'otel.jmx.target.system' or 'otel.jmx.config' must be set"); } - @Test - void shouldFailValidation_invalidTargetSystem() { + @ParameterizedTest + @EnumSource(JmxScraperConfig.TargetSystemSource.class) + void shouldFailValidation_invalidTargetSystem(JmxScraperConfig.TargetSystemSource source) { // Given Properties properties = (Properties) validProperties.clone(); properties.setProperty(JMX_TARGET_SYSTEM, "hal9000"); + properties.setProperty(JMX_TARGET_SOURCE, source.name().toLowerCase(Locale.ROOT)); // When and Then assertThatThrownBy(() -> fromConfig(TestUtil.configProperties(properties))) @@ -150,62 +156,82 @@ void shouldFailValidation_invalidTargetSystem() { .hasMessageStartingWith("unsupported target system"); } - // TODO: Tests below will be reimplemented - - // @Test - // @SetSystemProperty(key = "otel.jmx.service.url", value = "myServiceUrl") - // @SetSystemProperty(key = "javax.net.ssl.keyStorePassword", value = "truth") - // void propertiesFileOverride() { - // Properties props = new Properties(); - // JmxMetrics.loadPropertiesFromPath( - // props, ClassLoader.getSystemClassLoader().getResource("all.properties").getPath()); - // JmxConfig config = new JmxConfig(props); - // - // // This property should retain the system property value, not the config file value - // assertThat(config.serviceUrl).isEqualTo("myServiceUrl"); - // // These properties are set from the config file - // assertThat(config.groovyScript).isEqualTo("/my/groovy/script"); - // assertThat(config.targetSystem).isEqualTo("jvm,cassandra"); - // assertThat(config.targetSystems).containsOnly("jvm", "cassandra"); - // assertThat(config.intervalMilliseconds).isEqualTo(20000); - // assertThat(config.metricsExporterType).isEqualTo("otlp"); - // assertThat(config.otlpExporterEndpoint).isEqualTo("https://myotlpendpoint"); - // assertThat(config.prometheusExporterHost).isEqualTo("host123.domain.com"); - // assertThat(config.prometheusExporterPort).isEqualTo(67890); - // assertThat(config.username).isEqualTo("myUser\nname"); - // assertThat(config.password).isEqualTo("myPassw\\ord"); - // assertThat(config.remoteProfile).isEqualTo("SASL/DIGEST-MD5"); - // assertThat(config.realm).isEqualTo("myRealm"); - // - // // This property should retain the system property value, not the config file value - // assertThat(System.getProperty("javax.net.ssl.keyStorePassword")).isEqualTo("truth"); - // // These properties are set from the config file loading into JmxConfig - // assertThat(System.getProperty("javax.net.ssl.keyStore")).isEqualTo("/my/key/store"); - // assertThat(System.getProperty("javax.net.ssl.keyStoreType")).isEqualTo("JKS"); - // assertThat(System.getProperty("javax.net.ssl.trustStore")).isEqualTo("/my/trust/store"); - // assertThat(System.getProperty("javax.net.ssl.trustStorePassword")).isEqualTo("def456"); - // assertThat(System.getProperty("javax.net.ssl.trustStoreType")).isEqualTo("JKS"); - // } - // - // @Test - // @SetSystemProperty(key = "otel.jmx.service.url", value = "myServiceUrl") - // @SetSystemProperty(key = "otel.jmx.groovy.script", value = "myGroovyScript") - // @SetSystemProperty(key = "otel.jmx.target.system", value = "myTargetSystem") - // void canSupportScriptAndTargetSystem() { - // JmxConfig config = new JmxConfig(); - // - // assertThat(config.serviceUrl).isEqualTo("myServiceUrl"); - // assertThat(config.groovyScript).isEqualTo("myGroovyScript"); - // assertThat(config.targetSystem).isEqualTo("mytargetsystem"); - // assertThat(config.targetSystems).containsOnly("mytargetsystem"); - // } - // - // @Test - // @SetSystemProperty(key = "otel.metric.export.interval", value = "123") - // void otelMetricExportIntervalRespected() { - // JmxConfig config = new JmxConfig(); - // assertThat(config.intervalMilliseconds).isEqualTo(10000); - // assertThat(config.properties.getProperty("otel.metric.export.interval")).isEqualTo("123"); - // } - // + @ParameterizedTest + @ValueSource(strings = {"auto", ""}) + void targetSystemSource_auto(String source) { + Properties properties = (Properties) validProperties.clone(); + // we just need to provide a valid value for parsing + properties.setProperty(JMX_TARGET_SYSTEM, "fake-test-system-both"); + if (!source.isEmpty()) { + properties.setProperty(JMX_TARGET_SOURCE, source); + } + + JmxScraperConfig config = fromConfig(TestUtil.configProperties(properties)); + + // should resolve to instrumentation when available in both + shouldResolveToInstrumentationYaml(config, "fake-test-system-both"); + + // should resolve to legacy yaml when not available in instrumentation + shouldResolveToLegacyYaml(config, "fake-test-system-legacy-only"); + + // should resolve to instrumentation when only defined there + shouldResolveToInstrumentationYaml(config, "fake-test-system-instrumentation-only"); + } + + @Test + void targetSystemSource_legacy() { + Properties properties = (Properties) validProperties.clone(); + // we just need to provide a valid value for parsing + properties.setProperty(JMX_TARGET_SYSTEM, "fake-test-system-both"); + properties.setProperty(JMX_TARGET_SOURCE, "legacy"); + + JmxScraperConfig config = fromConfig(TestUtil.configProperties(properties)); + + shouldResolveToLegacyYaml(config, "fake-test-system-both"); + + shouldResolveToLegacyYaml(config, "fake-test-system-legacy-only"); + + // should not support system only defined in instrumentation + shouldNotResolveYaml(config, "fake-test-system-instrumentation-only"); + } + + @Test + void targetSystemSource_instrumentation() { + Properties properties = (Properties) validProperties.clone(); + // we just need to provide a valid value for parsing + properties.setProperty(JMX_TARGET_SYSTEM, "fake-test-system-both"); + properties.setProperty(JMX_TARGET_SOURCE, "instrumentation"); + + JmxScraperConfig config = fromConfig(TestUtil.configProperties(properties)); + + shouldResolveToInstrumentationYaml(config, "fake-test-system-both"); + + // should not support system only defined in legacy + shouldNotResolveYaml(config, "fake-test-system-legacy-only"); + + shouldResolveToInstrumentationYaml(config, "fake-test-system-instrumentation-only"); + } + + private static InputStream getYaml(String path) { + return JmxScraperConfigTest.class.getClassLoader().getResourceAsStream(path); + } + + private static void shouldResolveToInstrumentationYaml(JmxScraperConfig config, String target) { + assertThat(config.getTargetSystemYaml(target)) + .describedAs("should resolve to instrumentation yaml") + .hasSameContentAs(getYaml("jmx/rules/" + target + ".yaml")); + } + + private static void shouldResolveToLegacyYaml(JmxScraperConfig config, String target) { + assertThat(config.getTargetSystemYaml(target)) + .describedAs("should resolve to legacy yaml") + .hasSameContentAs(getYaml(target + ".yaml")); + } + + private static void shouldNotResolveYaml(JmxScraperConfig config, String target) { + assertThatThrownBy(() -> config.getTargetSystemYaml(target)) + .describedAs("should not support system") + .isInstanceOf(ConfigurationException.class) + .hasMessageStartingWith("unsupported target system"); + } } diff --git a/jmx-scraper/src/test/resources/fake-test-system-both.yaml b/jmx-scraper/src/test/resources/fake-test-system-both.yaml new file mode 100644 index 000000000..941514b53 --- /dev/null +++ b/jmx-scraper/src/test/resources/fake-test-system-both.yaml @@ -0,0 +1,11 @@ +--- +# test system 1 that is in the same location as legacy yaml files +rules: + + - bean: java.lang:type=Runtime + mapping: + Uptime: + metric: custom.jvm.uptime + type: counter + unit: ms + desc: JVM uptime in milliseconds diff --git a/jmx-scraper/src/test/resources/fake-test-system-legacy-only.yaml b/jmx-scraper/src/test/resources/fake-test-system-legacy-only.yaml new file mode 100644 index 000000000..11fa09290 --- /dev/null +++ b/jmx-scraper/src/test/resources/fake-test-system-legacy-only.yaml @@ -0,0 +1,11 @@ +--- +# test system 2 that is in the same location as legacy yaml files and is not suppored in instrumentation +rules: + + - bean: java.lang:type=Runtime + mapping: + Uptime: + metric: custom.jvm.uptime + type: counter + unit: ms + desc: JVM uptime in milliseconds diff --git a/jmx-scraper/src/test/resources/jmx/rules/fake-test-system-both.yaml b/jmx-scraper/src/test/resources/jmx/rules/fake-test-system-both.yaml new file mode 100644 index 000000000..2a8f6ecba --- /dev/null +++ b/jmx-scraper/src/test/resources/jmx/rules/fake-test-system-both.yaml @@ -0,0 +1,11 @@ +--- +# test system 1 that is in the same location as instrumentation yaml files +rules: + + - bean: java.lang:type=Runtime + mapping: + Uptime: + metric: custom.jvm.uptime + type: counter + unit: ms + desc: JVM uptime in milliseconds diff --git a/jmx-scraper/src/test/resources/jmx/rules/fake-test-system-instrumentation-only.yaml b/jmx-scraper/src/test/resources/jmx/rules/fake-test-system-instrumentation-only.yaml new file mode 100644 index 000000000..b3e98f505 --- /dev/null +++ b/jmx-scraper/src/test/resources/jmx/rules/fake-test-system-instrumentation-only.yaml @@ -0,0 +1,11 @@ +--- +# test system 3 that is in the same location as instrumentation yaml files and is NOT defined in legacy +rules: + + - bean: java.lang:type=Runtime + mapping: + Uptime: + metric: custom.jvm.uptime + type: counter + unit: ms + desc: JVM uptime in milliseconds