Skip to content

Conversation

@SylvainJuge
Copy link
Contributor

@SylvainJuge SylvainJuge commented Sep 17, 2025

Fixes #2206

JMX scraper initialization have to be modified as

  • we need to have the effective configuration from the properties customizer
  • we need the effective configuration to establish connection to the remote JVM, and thus generate a stable UUID.

This is using an UUID v3 which relies on MD5, however this should be fine because it's only used to fingerprint JVM identity, apart from potentially confusing duplicated metrics there is no potential security risk involved.

Testing of this feature is done through what the tool reports on the standard output, like the "connection test" feature. Having proper end-to-end testing would require to validate the data sent to the otlp collector, and there is currently no such test, which means it would likely require a larger effort to be implemented. I think this shortcut is however fine given the feature only removes the natural randomness of service.instance.id resource attribute in the context of metrics captured through JMX.


class PropertiesCustomizerTest {

private static final String DUMMY_URL = "service:jmx:rmi:///jndi/rmi://host:999/jmxrmi";
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 now have to test with an URL that can be parsed because the parsing is triggered, while it used to not be parsed previously.

@SylvainJuge SylvainJuge marked this pull request as ready for review September 18, 2025 08:33
@SylvainJuge SylvainJuge requested a review from a team as a code owner September 18, 2025 08:33
Copy link
Contributor

@breedx-splk breedx-splk left a comment

Choose a reason for hiding this comment

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

Looks good. Had a couple comments, but this is nice work. Thanks.

Comment on lines +155 to +162
ObjectName objectName = new ObjectName("java.lang:type=Runtime");
for (String attribute : Arrays.asList("StartTime", "Name")) {
Object value = connection.getAttribute(objectName, attribute);
if (id.length() > 0) {
id.append(" ");
}
id.append(value);
}
Copy link
Contributor

Choose a reason for hiding this comment

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

The description in #2206 includes the Pid but it's missing here. Is that intentional? Maybe the start time is enough....but I like the idea of including the pid, because time might introduce an edge case.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Including the Pid is the first thing that failed when testing with Java8, so it must have been added in a later JVM version. From what I've seen so far it's implicitly included in the Name attribute which is usually in the 1234@hostname format, where 1234 is the PID.

Copy link
Contributor

@breedx-splk breedx-splk left a comment

Choose a reason for hiding this comment

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

Nice!

@SylvainJuge
Copy link
Contributor Author

@breedx-splk can you merge it ?

@breedx-splk breedx-splk added this pull request to the merge queue Sep 23, 2025
Merged via the queue into open-telemetry:main with commit b373e2e Sep 23, 2025
25 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[jmx-scraper] implement stable service.instance.id

3 participants