Skip to content

Conversation

@scottopell
Copy link
Collaborator

@scottopell scottopell commented Apr 10, 2023

eCurrently there is a periodic refresh of the beans (and their attributes) which can result in CPU spikes as these remote RMI calls are expensive.

This PR implements a "subscription mode" for instances where a javax.management.NotificationListener is used to subscribe to bean registration/unregistration events.
This approach should spread out the expensive RMI calls over time and will reduce the total amount of calls needed.

Status @ Feb 8 2024:
This branch is showing flakey tests, so they need to be investigated before this can be merged.
Once this branch is clean, I intend to merge this and publish a SNAPSHOT build which can be used in nightly agent builds to get validation. This agent branch is required before the snapshot/nightly.

Latest flakey report: Ran 2000 times, 4 failures found

@scottopell
Copy link
Collaborator Author

scottopell commented May 22, 2023

  • Can audit logging answer "Were there any beans missed?"
  • Simplify bean subscription creation, can execute on main thread
  • Add more tests around metric counting (ie, if we reach maxMetrics and new bean subscription arrives, do we properly ignore it? If we reach maxMetrics and a new bean unregistration arrives, do we properly decrement the metric count?)
  • What is recommended configuration for internal testing?
  • Add metrics around instance count, collection time, metrics collected, etc (basically jmxfetch telemetry) (too much scope creep, not doing this)
  • Remove explicit lock in favor of synchronized
  • Process bean notifications on dedicated thread to allow all notifications to arrive unscathed

return;
}
MBeanServerNotification mbs = (MBeanServerNotification) notification;
queue.offer(mbs);
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we want to do anything here if we get false back? Maybe log/warn we couldn't add the MBeanServerNotification?

@scottopell scottopell force-pushed the feat/bean-listener branch from b93caeb to 79ce047 Compare July 5, 2023 20:32
# Conflicts:
#	src/main/java/org/datadog/jmxfetch/Instance.java
#	src/main/java/org/datadog/jmxfetch/JmxAttribute.java
#	src/test/java/org/datadog/jmxfetch/TestCommon.java
@scottopell scottopell requested a review from a team as a code owner December 27, 2023 21:07
@scottopell scottopell requested a review from a team December 27, 2023 21:07
Copy link

@apigirl apigirl left a comment

Choose a reason for hiding this comment

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

editorial feedback

@scottopell scottopell requested a review from a team as a code owner October 28, 2025 16:47
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.

5 participants