Skip to content

Commit

Permalink
Issue 9336: Auto-instrumentation with JMX not working without a trigger
Browse files Browse the repository at this point in the history
Forcing initialization of PlatformMBeanServer.
  • Loading branch information
PeterF778 committed Aug 31, 2023
1 parent 32614d5 commit 1a05b88
Showing 1 changed file with 8 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

package io.opentelemetry.instrumentation.jmx.engine;

import java.lang.management.ManagementFactory;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
Expand Down Expand Up @@ -38,6 +39,13 @@ class BeanFinder {
void discoverBeans(MetricConfiguration conf) {
this.conf = conf;

if (!conf.isEmpty()) {
// Issue 9336: Corner case: PlatformMBeanServer will remain unitialized until a direct
// reference to it is made. This call makes sure that the PlatformMBeanServer will be in
// the set of MBeanServers reported by MBeanServerFactory.
ManagementFactory.getPlatformMBeanServer();
}

exec.schedule(
new Runnable() {
@Override
Expand Down

0 comments on commit 1a05b88

Please sign in to comment.