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

Fix jmx-metrics on wildfly #11151

Merged
merged 1 commit into from
Apr 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -33,23 +33,22 @@ public void afterAgent(AutoConfiguredOpenTelemetrySdk autoConfiguredSdk) {

if (config.getBoolean("otel.jmx.enabled", true)) {
JmxMetricInsight service =
JmxMetricInsight.createService(GlobalOpenTelemetry.get(), beanDiscoveryDelay(config));
JmxMetricInsight.createService(
GlobalOpenTelemetry.get(), beanDiscoveryDelay(config).toMillis());
MetricConfiguration conf = buildMetricConfiguration(config);
service.start(conf);
}
}

private static long beanDiscoveryDelay(ConfigProperties configProperties) {
Long discoveryDelay = configProperties.getLong("otel.jmx.discovery.delay");
private static Duration beanDiscoveryDelay(ConfigProperties configProperties) {
Duration discoveryDelay = configProperties.getDuration("otel.jmx.discovery.delay");
if (discoveryDelay != null) {
return discoveryDelay;
}

// If discovery delay has not been configured, have a peek at the metric export interval.
// It makes sense for both of these values to be similar.
return configProperties
.getDuration("otel.metric.export.interval", Duration.ofMinutes(1))
.toMillis();
return configProperties.getDuration("otel.metric.export.interval", Duration.ofMinutes(1));
}

private static String resourceFor(String platform) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,18 @@ 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(
() -> {
// 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.
// Issue 11143: This call initializes java.util.logging.LogManager. We should not call it
// before application has had a chance to configure custom log manager. This is needed for
// wildfly.
ManagementFactory.getPlatformMBeanServer();
},
discoveryDelay,
TimeUnit.MILLISECONDS);

exec.schedule(
new Runnable() {
Expand Down
Loading