Skip to content

refactor!: remove deprecated SysMonitor - #20200

Open
FrankChen021 wants to merge 8 commits into
apache:masterfrom
FrankChen021:codex/remove-deprecated-sysmonitor
Open

refactor!: remove deprecated SysMonitor#20200
FrankChen021 wants to merge 8 commits into
apache:masterfrom
FrankChen021:codex/remove-deprecated-sysmonitor

Conversation

@FrankChen021

@FrankChen021 FrankChen021 commented Aug 31, 2026

Copy link
Copy Markdown
Member

Fixes #10615.

Description

The deprecated org.apache.druid.java.util.metrics.SysMonitor monitor is removed. Its no-op variant, unused Druid subclass, Guice provider, and obsolete tests are removed as well.

JvmCpuMonitor now uses OSHI process snapshots to report the existing total, user, system, and percentage CPU metrics. JvmPidDiscoverer uses Java ProcessHandle to discover the current JVM PID. The Sigar PID discoverer and utility, native library packaging, Maven dependencies, and associated tests have been removed.

Existing configurations that list SysMonitor in druid.monitoring.monitors must be updated to use org.apache.druid.java.util.metrics.OshiSysMonitor.

The metrics documentation now documents only OshiSysMonitor.

Release note

SysMonitor has been removed after being deprecated in Druid 27. Use OshiSysMonitor instead.

Validation

  • mvn -ntp test -pl processing,server -am -Dtest="org.apache.druid.java.util.metrics.JvmCpuMonitorTest,org.apache.druid.java.util.metrics.JvmPidDiscovererTest,org.apache.druid.java.util.metrics.OshiSysMonitorTest,org.apache.druid.java.util.metrics.NoopOshiSysMonitorTest,org.apache.druid.server.metrics.MetricsModuleTest" -Dsurefire.failIfNoSpecifiedTests=false -Pskip-static-checks -Dweb.console.skip=true -T1C
  • npm run spellcheck

Copilot AI lite review requested due to automatic review settings August 31, 2026 15:09

Copilot AI 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.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@FrankChen021 FrankChen021 left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Severity Findings
P0 0
P1 0
P2 1
P3 0
Total 1
Severity Findings
P0 0
P1 0
P2 1
P3 0
Total 1

Reviewed 19 of 19 changed files.


This is an automated review by Codex GPT-5.6-Luna(max)

final ServiceMetricEvent.Builder builder = builder();
final long userTime = currentProcess.getUserTime();
final long sysTime = currentProcess.getKernelTime();
final Map<String, Long> procDiff = diff.to(

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

[P2] Do not advance the diff on failed OSHI snapshots

OperatingSystem.getCurrentProcess() is non-null by contract: when the native lookup fails it returns a CurrentProcessStub with zero or unknown fields. Because this code only checks for null, that stub is fed into KeyedDiff and then stored as previousProcess, emitting bogus zero deltas and making the next successful sample compare against the zero snapshot. Detect an invalid snapshot and leave the diff and previous-process state unchanged when OSHI cannot read the process.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Addressed in the latest commit. JvmCpuMonitor now uses the nullable OperatingSystem.getProcess(pid) API, so a failed lookup is skipped before either KeyedDiff or previousProcess is updated. This prevents failed snapshots from producing bogus deltas or poisoning the next CPU percentage calculation.

Added a regression test covering a valid snapshot, a failed lookup, and the next valid snapshot; the original baselines are preserved.

Validation: 16 focused processing tests passed; Checkstyle reported 0 violations.

Reviewed 2 of 2 affected files.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

SysMonitor is throwing 'SigarFileNotFoundException' in official Docker images

2 participants