Skip to content

Fix consumers of JVM CPU metrics renamed by OTel Prometheus exporter update - #4711

Open
janhoy wants to merge 5 commits into
apache:mainfrom
janhoy:fix-jvm-cpu-utilization-metric-name
Open

Fix consumers of JVM CPU metrics renamed by OTel Prometheus exporter update#4711
janhoy wants to merge 5 commits into
apache:mainfrom
janhoy:fix-jvm-cpu-utilization-metric-name

Conversation

@janhoy

@janhoy janhoy commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

The Telemetry update in #4594 brought in a Prometheus exporter (1.57+) that no longer maps OTel unit "1" to a _ratio name suffix, renaming jvm_system_cpu_utilization_ratiojvm_system_cpu_utilization and jvm_cpu_recent_utilization_ratiojvm_cpu_recent_utilization. This broke replica placement attribute fetching (CI failure in PlacementPluginIntegrationTest.testAttributeFetcherImpl) and silently broke CPUCircuitBreaker (calculateLiveCPUUsage() returned -1).

  • Update the internal consumers (NodeMetricImpl, NodeValueFetcher, CPUCircuitBreaker) to the new metric names
  • Document the Prometheus metric rename in the Solr 10.1 upgrade notes (major-changes-in-solr-10.adoc), since 9x and 10x will also get this OTel upgrade — no back-compat shim
  • Add a TestCircuitBreakers test asserting calculateLiveCPUUsage() returns >= 0, gated by an independent native-CPU probe (com.sun.management.OperatingSystemMXBean.getCpuLoad()) so a future metric-name regression fails instead of being mistaken for an unsupported machine

janhoy added 3 commits August 5, 2026 12:36
The OpenTelemetry Prometheus exporter 1.63 (updated in apache#4594) no longer
maps unit "1" to a "_ratio" name suffix, so the JVM metric previously
exposed as jvm_system_cpu_utilization_ratio is now exposed as
jvm_system_cpu_utilization. Update the three consumers still using the
old name: NodeMetricImpl.SYSLOAD_AVG and NodeValueFetcher.SYSLOADAVG
(broke PlacementPluginIntegrationTest.testAttributeFetcherImpl / replica
placement attribute fetching) and CPUCircuitBreaker (silently returned
-1 for CPU usage).
The OTel Prometheus exporter rename of jvm_system_cpu_utilization_ratio
and jvm_cpu_recent_utilization_ratio (unit "1" no longer maps to a
_ratio suffix) breaks dashboards, alerts and API clients using the old
names. FilterablePrometheusMetricReader now duplicates these gauges
under their legacy names, in both full scrapes and name-filtered
/admin/metrics requests.
@janhoy
janhoy requested review from dsmiley and mlbiscoc August 5, 2026 11:09

@dsmiley dsmiley left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks for catching this!

FWIW I think no need for metric name backwards-compatibility break in 10.1.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

wow; I suppose whatever tests exist for CPU circuit breaker are really lacking.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yea, totally.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

TestCircuitBreakers should add a check that org.apache.solr.util.circuitbreaker.CPUCircuitBreaker#calculateLiveCPUUsage returns >= 0 (not -1).

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Problem was that it was impossible to distinguish if the -1 was because the JVM did not expose cpu usage or because wrong metric name was used. Have added a separate test for whether cpu is available at all, and now assert that liveCPUUsage() returns >0.

@janhoy

janhoy commented Aug 5, 2026

Copy link
Copy Markdown
Contributor Author

FWIW I think no need for metric name backwards-compatibility break in 10.1.

Meaning you agree with the aliasing of metric name? A bit confused by your "no need for" wording.

@dsmiley

dsmiley commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

Sorry; my statement was highly ambiguous. I mean we needn't bother trying to be backwards-compatible with the 10.0 name, IMO.

…s; test CPU breaker

Per review, remove the FilterablePrometheusMetricReader alias shim and
instead document the jvm_system_cpu_utilization / jvm_cpu_recent_utilization
Prometheus renames in major-changes-in-solr-10.adoc under 10.1. Add a
TestCircuitBreakers test asserting calculateLiveCPUUsage() >= 0, gated by an
independent native-CPU probe so a metric-name regression fails rather than
being mistaken for an unsupported machine.
@github-actions github-actions Bot added documentation Improvements or additions to documentation and removed cat:metrics labels Aug 6, 2026
@janhoy

janhoy commented Aug 6, 2026

Copy link
Copy Markdown
Contributor Author

Sorry; my statement was highly ambiguous. I mean we needn't bother trying to be backwards-compatible with the 10.0 name, IMO.

I dropped the shim and instead added a bullet in upgrade-notes about the name change.

@janhoy
janhoy requested a review from dsmiley August 6, 2026 09:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cat:cloud client:solrj documentation Improvements or additions to documentation tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants