Skip to content

Fix continuous profiling policy validation: reject zero threshold/count#13898

Open
mrproliu wants to merge 2 commits into
apache:masterfrom
mrproliu:fix/continuous-profiling-validation-zero-threshold
Open

Fix continuous profiling policy validation: reject zero threshold/count#13898
mrproliu wants to merge 2 commits into
apache:masterfrom
mrproliu:fix/continuous-profiling-validation-zero-threshold

Conversation

@mrproliu

@mrproliu mrproliu commented Jun 8, 2026

Copy link
Copy Markdown
Contributor

Fix [Bug] Continuous profiling policy validation: condition doesn't match error message (#13832)

  • Add a unit test to verify that the fix works.
  • Explain briefly why the bug exists and how to fix it.

In ContinuousProfilingMutationService.validatePolicyItem() / validatePolicyItemWindows(), the validation conditions used < 0 while the error messages said "must bigger than zero". The condition therefore accepted 0, contradicting the message.

0 is not a meaningful threshold. In skywalking-rover the profiling trigger fires when value >= threshold (system_checker.go, http_checker.go) and a time window matches when matchedCount >= count (windows.go). A threshold or count of 0 is always satisfied, i.e. it would trigger profiling unconditionally.

Fix (Option A — fix the condition to match the message semantics):

  • PROCESS_THREAD_COUNT, SYSTEM_LOAD, HTTP_AVG_RESPONSE_TIME: < 0<= 0.

  • count window check: < 0<= 0 (same bug, not flagged in the issue).

  • PROCESS_CPU, HTTP_ERROR_RATE: tightened from [0-100] to (0-100] for consistency (a 0% threshold also always triggers).

  • Fixed message grammar: "must bigger than zero" → "must be bigger than zero", "small than" → "smaller than".

  • If this pull request closes/resolves/fixes an existing issue, replace the issue number. Closes [Bug] Continuous profiling policy validation: condition doesn't match error message #13832.

  • Update the `CHANGES` log.

…ount

The validation conditions used `< 0` while the error messages said
"must bigger than zero". rover triggers profiling when `value >= threshold`
(and `matchedCount >= count`), so a threshold/count of 0 always fires and is
meaningless. Tighten the conditions to `<= 0`, align CPU percent / HTTP error
rate to (0-100], and fix the message grammar.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@mrproliu mrproliu requested a review from Copilot June 8, 2026 07:58
@mrproliu mrproliu added the enhancement Enhancement on performance or codes label Jun 8, 2026
@mrproliu mrproliu added this to the 11.0.0 milestone Jun 8, 2026

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes continuous profiling policy validation in OAP so that thresholds/counts of 0 are rejected, aligning the validation logic with the existing error-message semantics and preventing “always-trigger” policies. It also updates the change log to document the behavioral tightening.

Changes:

  • Tighten validation for continuous profiling thresholds/counts to reject 0 (e.g., <= 0 instead of < 0) and narrow percent-based thresholds from [0-100] to (0-100].
  • Improve several validation error messages’ grammar (e.g., “must be bigger than zero”, “smaller than”).
  • Add a CHANGES entry documenting the new rejection behavior and the percent-range tightening.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/profiling/continuous/ContinuousProfilingMutationService.java Tightens policy item validation to reject zero thresholds/counts and adjusts related messages.
docs/en/changes/changes.md Documents the validation tightening and the effect on threshold ranges.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@mrproliu mrproliu requested a review from wu-sheng June 8, 2026 13:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement Enhancement on performance or codes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] Continuous profiling policy validation: condition doesn't match error message

2 participants