fix: full app profiling for changing worker ids#1192
Open
ferhatelmas wants to merge 1 commit into
Open
Conversation
Signed-off-by: ferhat elmas <elmas.ferhat@gmail.com>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes whole-app pprof captures when Platformatic Watt worker IDs are no longer dense/zero-based (as seen after wattpm updates), by resolving live worker IDs from more reliable sources and retrying capture when the initial worker set is invalid.
Changes:
- Enable the Watt management
getWorkersoperation and prefer it to discover live worker IDs for profiling targets. - Enhance runtime selection logic to extract worker IDs from runtime application details (when available) and fall back to count-based IDs only when necessary.
- Add a retry path in the admin pprof route that parses “worker not found” errors to recover and profile the live worker IDs; expand test coverage accordingly.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| watt.json | Enables management getWorkers operation so the app can query live workers for accurate pprof targeting. |
| src/internal/monitoring/pprof/runtime.ts | Adds worker-id normalization + management/runtime/error parsing helpers and updates selection logic to prefer live IDs. |
| src/internal/monitoring/pprof/runtime.test.ts | Adds unit tests for management-based selection, runtime worker-detail parsing, and error-message extraction. |
| src/http/routes/admin/pprof.ts | Adds retry-on-worker-not-found flow for whole-app captures and ensures cleanup on partial start failures. |
| src/http/routes/admin/pprof.test.ts | Adds an integration-style test that validates the retry behavior and resulting merged multipart response. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Coverage Report for CI Build 28588978488Coverage increased (+0.09%) to 78.907%Details
Uncovered Changes
Coverage RegressionsNo coverage regressions found. Coverage Stats💛 - Coveralls |
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.
What kind of change does this PR introduce?
Bug fix
What is the current behavior?
Worker ids are changing and doesn't start from zero since #1190
What is the new behavior?
Extract ids from management api, application or error message with retry in the desired order.