Skip to content

Conversation

@SylvainJuge
Copy link
Contributor

@SylvainJuge SylvainJuge commented Nov 20, 2025

There was an oversight in #15220, which I unfortunately only discovered when plumbing this new API in jmx-scraper with open-telemetry/opentelemetry-java-contrib#2446.

This PR adds a more versatile JmxTelemetryBuilder#addRules as replacement, this allows to load JMX metrics rules from any InputStream, not only the classpath resources in jmx/rules.

The following methods are not yet annotated with @Deprecated to prevent having to deal with changes when the dependency of contrib to instrumentation is updated, they should be replaced with JmxTelemetryBuilder#addRules in the future:

  • JmxTelemetryBuilder#addClassPathRules
  • JmxTelemetryBuilder#addCustomRules

This limitation currently makes loading "legacy" metrics definitions in jmx-scraper more complicated than necessary (see open-telemetry/opentelemetry-java-contrib#2446 for details).

* @return builder instance
* @throws IllegalArgumentException when classpath resource does not exist or can't be parsed
*/
// TODO: deprecate this method after 2.23.0 release in favor of addRules
Copy link
Contributor

Choose a reason for hiding this comment

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

why don't you deprecate it immediately?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If we deprecate it right now, it means the next update of instrumentation dependency in contrib will require to immediately modify the code of jmx-scraper in contrib to switch to the new API. Even if the changes are minor it's an added constraint on the dependency update.

Doing that after 2.23.0 gives a bit more time with a timeline like this:

  • instrumentation 2.23.0 is released with this new API
  • contrib gets updated to use 2.23.0 dependency
  • we update jmx-scraper to use the new API introduced by this PR
  • we deprecate methods in this API, this will likely be for the 2.24.0 release

@trask trask added this to the v2.23.0 milestone Dec 1, 2025
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.

4 participants