feat: add process info diagnostic for cpu, memory, and system metrics#10204
feat: add process info diagnostic for cpu, memory, and system metrics#10204GiladShoham wants to merge 2 commits intomasterfrom
Conversation
There was a problem hiding this comment.
Pull request overview
This PR adds a new getProcessInfo diagnostic function to report detailed process and system metrics alongside the existing getBitVersion diagnostic. The function collects process uptime, PID, memory usage, CPU usage, and system information (total/free memory, CPU count, load average, hostname). Comprehensive unit tests are included to validate the new functionality.
Changes:
- Added
getProcessInfostatic method toDiagnosticMainclass that collects process and system metrics - Registered
getProcessInfoalongsidegetBitVersionin the diagnostic slot - Updated diagnostic route verb from READ to WRITE and added explicit return statement
- Disabled GraphQL diagnostic resolver (returns empty object instead of diagnostic data)
- Added comprehensive unit tests for both
getBitVersionandgetProcessInfomethods
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| scopes/harmony/diagnostic/diagnostic.spec.ts | New test file with comprehensive tests for getBitVersion and getProcessInfo functions |
| scopes/harmony/diagnostic/diagnostic.main.runtime.ts | Added getProcessInfo method and registered it in the provider |
| scopes/harmony/diagnostic/diagnostic.route.ts | Changed verb to WRITE and added explicit return to res.json |
| scopes/harmony/diagnostic/diagnostic.graphql.ts | Commented out diagnostic data retrieval, now returns empty object |
| method = 'GET'; | ||
| route = '/_diagnostic'; | ||
| verb = Verb.READ; | ||
| verb = Verb.WRITE; |
There was a problem hiding this comment.
The verb should be Verb.READ instead of Verb.WRITE. The /_diagnostic endpoint only reads diagnostic data without modifying any state. Based on the codebase patterns:
Verb.READis used for GET requests that query data without side effects (e.g., fetch routes, search routes, query routes)Verb.WRITEis used for POST requests that modify state (e.g., create, delete, put routes)
This is a GET request that only reads diagnostic information, so it should use Verb.READ.
| verb = Verb.WRITE; | |
| verb = Verb.READ; |
| // return this.diagnosticMain.getDiagnosticData(); | ||
| return {}; |
There was a problem hiding this comment.
The GraphQL resolver for _diagnostic has been commented out and now returns an empty object. This breaks the GraphQL API functionality. If the intention is to disable this temporarily, it should either be removed completely or have a clear explanation/TODO comment. If this is intentional and permanent, the schema and resolver should be removed entirely.
This change is not mentioned in the PR description and appears to be unrelated to adding the getProcessInfo diagnostic function.
Add
getProcessInfodiagnostic that reports process uptime, pid, memory usage, CPU usage, and system info (total/free memory, CPU count, load average, hostname). Registered alongsidegetBitVersionin the diagnostic slot. Includes unit tests.