This is an automated email from the ASF dual-hosted git repository.
mlbiscoc pushed a commit to branch branch_10x
in repository https://gitbox.apache.org/repos/asf/solr.git
The following commit(s) were added to refs/heads/branch_10x by this push:
new a336bf871b2 SOLR-18544: Source CPU utilization metric from JFR instead
JMX (#5185)
a336bf871b2 is described below
commit a336bf871b2c2b67abe55808966051d1c553b579
Author: Matthew Biscocho <[email protected]>
AuthorDate: Tue Oct 27 15:42:00 2026 -0400
SOLR-18544: Source CPU utilization metric from JFR instead JMX (#5185)
Partially a regression from SOLR-18407 but also partially a JDK bug that
got exposed from the OTEL upgrade.
This was because previously the metric was sourced from JFR. Then after the
upgrade it started to source it from JMX which failed to some JDK bug. So this
change just sources it from JFR again.
---
.../src/java/org/apache/solr/metrics/OtelRuntimeJvmMetrics.java | 6 ++++++
1 file changed, 6 insertions(+)
diff --git
a/solr/core/src/java/org/apache/solr/metrics/OtelRuntimeJvmMetrics.java
b/solr/core/src/java/org/apache/solr/metrics/OtelRuntimeJvmMetrics.java
index a5941b003fe..6a2c4d25304 100644
--- a/solr/core/src/java/org/apache/solr/metrics/OtelRuntimeJvmMetrics.java
+++ b/solr/core/src/java/org/apache/solr/metrics/OtelRuntimeJvmMetrics.java
@@ -24,11 +24,13 @@ import io.opentelemetry.api.metrics.MeterProvider;
import io.opentelemetry.api.metrics.ObservableLongGauge;
import io.opentelemetry.api.trace.TracerProvider;
import io.opentelemetry.context.propagation.ContextPropagators;
+import io.opentelemetry.instrumentation.api.config.IncludeExclude;
import io.opentelemetry.instrumentation.runtimetelemetry.RuntimeTelemetry;
import
io.opentelemetry.instrumentation.runtimetelemetry.RuntimeTelemetryBuilder;
import io.opentelemetry.instrumentation.runtimetelemetry.internal.Experimental;
import java.lang.invoke.MethodHandles;
import java.lang.management.ManagementFactory;
+import java.util.List;
import org.apache.lucene.util.SuppressForbidden;
import org.apache.solr.common.util.EnvUtils;
import org.apache.solr.metrics.otel.OtelUnit;
@@ -84,6 +86,10 @@ public class OtelRuntimeJvmMetrics {
// solr.metrics.jvm.* system property instead of hardcoding true/true here.
Experimental.setEmitExperimentalMetrics(builder, true);
Experimental.setEmitExperimentalJfrMetrics(builder, true);
+ // Get CPU utilization from JFR instead of JMX to work around JDK bugs
+ Experimental.setJfrMetrics(
+ builder,
+
IncludeExclude.builder().setIncluded(List.of("jvm.system.cpu.utilization")).build());
this.runtimeMetrics = builder.build();
java.lang.management.OperatingSystemMXBean osMxBean =
ManagementFactory.getOperatingSystemMXBean();