Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

jmx reuse instrumentation metrics #1782

Merged
merged 7 commits into from
Mar 12, 2025

Conversation

SylvainJuge
Copy link
Contributor

@SylvainJuge SylvainJuge commented Mar 6, 2025

Adds a new configuration for jmx scraper: otel.jmx.target.source that defines how the values of otel.jmx.target.system are resolved to their respective YAML definitions.

3 possible values:

  • auto (default) use instrumentation yaml if available, fallback to embedded if possible
  • legacy only use the embedded yaml (which is very close to JMX gatherer)
  • instrumentation only use the instrumentation yaml without fallback

Thanks @robsunday for the idea of an automatic fallback, that will really help with the migration to having everything defined in instrumentation. In short, the metrics produced by default will be the ones from instrumentation repository (in the "library" part, not the "javaagent" as they currently are), so every release and update of instrumentation dependency will bring an updated set of metrics. For example this will be the case for jvm system that will be added with open-telemetry/opentelemetry-java-instrumentation#13392 pull-request.

I have tested it locally with a snapshot build of open-telemetry/opentelemetry-java-instrumentation#13392 to have the JVM metrics included in instrumentation, so as the time of writing this is "works on my computer certified".

Verified

This commit was signed with the committer’s verified signature.
ljharb Jordan Harband

Verified

This commit was signed with the committer’s verified signature.
ljharb Jordan Harband

Verified

This commit was signed with the committer’s verified signature.
ljharb Jordan Harband

Verified

This commit was signed with the committer’s verified signature.
ljharb Jordan Harband

Verified

This commit was signed with the committer’s verified signature.
ljharb Jordan Harband
Comment on lines +63 to +74
| `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) | |
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[for reviewer] this table will have to be updated on every instrumentation dependency release if there are new systems or definitions in instrumentation.

Comment on lines 35 to 40
// 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")
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[for reviewer] leaving this is intentional for now as it ensures that the test will fail when the open-telemetry/opentelemetry-java-instrumentation#13392 PR has been merged, released and the dependency has been updated. Because we don't know yet when that will happen I think this is better than to forget about it. Also, this is a good reminder that we need to update the table in README for the supported systems.

* @return input stream on target system yaml definitions
* @throws ConfigurationException when no yaml for system is available
*/
public InputStream getTargetSystemYaml(String system) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[for reviewer] technically speaking this could be left outside of configuration however we now have to use the presence of yaml files to check if system is supported, which is something that the configuration should check for (this is already tested in tests like JmxScraperConfigTest#shouldFailValidation_invalidTargetSystem).

// assertThat(config.properties.getProperty("otel.metric.export.interval")).isEqualTo("123");
// }
//
@ParameterizedTest
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[for reviewer] we could do the same tests with "real" yaml systems definitions, but this is not possible because we need to cover all the cases where a system is exclusively supported in legacy or instrumentation and when it's in both, in which case the priority will depend on the value of otel.jmx.target.source.

@SylvainJuge SylvainJuge marked this pull request as ready for review March 6, 2025 15:19
@SylvainJuge SylvainJuge requested a review from a team as a code owner March 6, 2025 15:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants