Fix high memory alert ratio - #2
Open
jarlyn95 wants to merge 1 commit into
Open
Conversation
There was a problem hiding this comment.
Pull request overview
Adjusts the recommended Prometheus HighMemoryUsage alert expression to use a meaningful memory ratio and adds a pre-upload validation step (with tests) to prevent self-division regressions in alert rules.
Changes:
- Fix
HighMemoryUsageexpression to compareprocess_resident_memory_bytesagainstmachine_memory_bytes. - Add alert-expression validation in
upload_prometheus_rules()and unit tests for both recommended rules and a self-division regression. - Fix a
build.pyf-string/quoting issue and commit diagnostic build artifacts.
Reviewed changes
Copilot reviewed 4 out of 5 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| tools/monitoring_setup.py | Updates HighMemoryUsage and adds self-division validation before uploading rules. |
| tools/test_monitoring_setup.py | Adds unittests covering recommended rules and a self-division regression case. |
| build.py | Fixes printing of a string containing an apostrophe. |
| diagnostic/build-2b54872c.json | Adds build diagnostic metadata for the PR. |
| diagnostic/build-2b54872c.logd | Adds the encrypted diagnostic bundle referenced by the JSON metadata. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+21
to
+22
| self.assertIn("process_resident_memory_bytes", rule["expr"]) | ||
| self.assertIn("machine_memory_bytes", rule["expr"]) |
Comment on lines
+201
to
+208
| METRIC_REF_RE = r"[A-Za-z_:][A-Za-z0-9_:]*(?:\s*\{[^{}]*\})?(?:\s*\[[^\[\]]+\])?" | ||
| DIVISION_RE = re.compile( | ||
| rf"(?<![A-Za-z0-9_:])(?P<left>{METRIC_REF_RE})\s*/\s*(?P<right>{METRIC_REF_RE})(?![A-Za-z0-9_:])" | ||
| ) | ||
|
|
||
|
|
||
| def _normalize_metric_ref(metric_ref: str) -> str: | ||
| return re.sub(r"\s+", "", metric_ref) |
| "name": "frontend", | ||
| "status": "PASS", | ||
| "elapsed_seconds": 12.151, | ||
| "artifact": "/mnt/c/Users/jarlyn/Documents/make money/zeroeye-memory-bounty/frontend/dist", |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #1. The
HighMemoryUsagealert no longer dividesprocess_resident_memory_bytesby itself; it now compares resident process memory againstmachine_memory_bytes.Changes
HighMemoryUsageto useprocess_resident_memory_bytes / machine_memory_bytes > 0.9.build.pyf-string literal so the required build command can run on current Python versions..logdbundle frompython3 build.py.Testing
python -m py_compile build.py tools/monitoring_setup.py tools/test_monitoring_setup.pypython -m unittest tools.test_monitoring_setup -vpython tools/monitoring_setup.py --alerts --dry-runwsl python3 -m py_compile build.py tools/monitoring_setup.py tools/test_monitoring_setup.pywsl python3 -m unittest tools.test_monitoring_setup -vwsl python3 build.pygenerateddiagnostic/build-2b54872c.logdanddiagnostic/build-2b54872c.json; it exited non-zero because this local WSL environment is missing most non-frontend toolchains, while the frontend module passed.Checklist