Repository navigation
chore: disable pyroscope for primary process in cluster mode - #4756
Conversation
|
Note
|
| Cohort / File(s) | Summary |
|---|---|
Cluster & Pyroscope changes src/index.ts |
Replaced direct cluster usage with a clusterUtil namespace import; added enablePyroscope which requires PYROSCOPE_SERVER_ADDRESS and cluster state (primary + CLUSTER_ENABLED); conditionalized Pyroscope init/start on enablePyroscope; call clusterUtil.start(port, app, metricsApp) when clustering is enabled. |
Sequence Diagram
sequenceDiagram
participant Entry as src/index.ts
participant ClusterUtil as clusterUtil
participant Cluster as cluster
participant Pyroscope as Pyroscope
participant App as App / metricsApp
Entry->>Cluster: read CLUSTER_ENABLED, cluster.isPrimary
Entry->>Entry: compute enablePyroscope = PYROSCOPE_SERVER_ADDRESS && (!CLUSTER_ENABLED || !cluster.isPrimary)
alt enablePyroscope == true
Entry->>Pyroscope: initialize & start
Pyroscope-->>Entry: running
else enablePyroscope == false
Entry->>Entry: log pyroscope disabled
end
alt CLUSTER_ENABLED == true
Entry->>ClusterUtil: clusterUtil.start(port, app, metricsApp)
ClusterUtil-->>Cluster: spawn/manage workers
else
Entry->>App: start server directly
end
Estimated code review effort
🎯 3 (Moderate) | ⏱️ ~20 minutes
Areas to focus on:
- Confirm
enablePyroscopelogic prevents duplicate profiling (primary vs worker) and matches intended semantics. - Verify
clusterUtil.start(port, app, metricsApp)signature and behavior match previouscluster.startsemantics (args, lifecycle, exit handling). - Ensure no code paths elsewhere assume Pyroscope was initialized unconditionally (startup ordering and error handling).
- Check logging and observability for clarity when Pyroscope is disabled.
Possibly related PRs
- chore(release): pull main into develop post release v1.107.3 #4591 — Alters Pyroscope initialization/control flow in
src/index.ts, closely overlapping gating changes. - fix: cluster node getting stuck and cluster left running in degraded mode #4447 — Switches cluster import/usage to a utility and introduces
clusterUtil.startpatterns. - chore: pyroscope setup #4578 — Changes Pyroscope initialization and middleware wiring; may interact with the new gating.
Suggested reviewers
- vinayteki95
- maheshkutty
- chandumlg
Pre-merge checks and finishing touches
❌ Failed checks (1 warning)
| Check name | Status | Explanation | Resolution |
|---|---|---|---|
| Docstring Coverage | Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. | You can run @coderabbitai generate docstrings to improve docstring coverage. |
✅ Passed checks (2 passed)
| Check name | Status | Explanation |
|---|---|---|
| Title check | ✅ Passed | The title accurately captures the main change: disabling Pyroscope for the primary process in cluster mode, which aligns with the raw summary and PR objectives. |
| Description check | ✅ Passed | The description covers all required template sections including changes, motivation, and related checklists, providing clear context for the Pyroscope cluster-mode optimization. |
✨ Finishing touches
- 📝 Generate docstrings
🧪 Generate unit tests (beta)
- Create PR with unit tests
- Post copyable unit tests in a comment
- Commit unit tests in branch
int-4203-pyroscope
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
Comment @coderabbitai help to get the list of available commands and usage tips.
There was a problem hiding this comment.
Actionable comments posted: 1
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
src/index.ts (1)
34-64: Update the log message to reflect all reasons Pyroscope may be disabled.The log message on line 63 is now misleading. Pyroscope can be disabled either because
PYROSCOPE_SERVER_ADDRESSis not set, or because the process is running as the primary in cluster mode. The current message only mentions the former.Consider updating the log message to be more accurate:
} else { - logger.info('Pyroscope disabled (PYROSCOPE_SERVER_ADDRESS not set)'); + logger.info( + `Pyroscope disabled (${ + !process.env.PYROSCOPE_SERVER_ADDRESS + ? 'PYROSCOPE_SERVER_ADDRESS not set' + : 'running as primary process in cluster mode' + })`, + ); }
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
src/index.ts(3 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
src/index.ts (1)
src/util/prometheus.js (1)
clusterEnabled(5-5)
🪛 GitHub Actions: Verify
src/index.ts
[error] 1-1: git diff --exit-code failed: differences detected in src/index.ts (added/removed import 'cluster'). Process completed with exit code 1.
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (9)
- GitHub Check: Build User Transformer Docker Image - PR / Build Transformer Docker Image ARM64
- GitHub Check: Build User Transformer Docker Image - PR / Build Transformer Docker Image AMD64
- GitHub Check: Build Transformer Docker Image - PR / Build Transformer Docker Image AMD64
- GitHub Check: Build Transformer Docker Image - PR / Build Transformer Docker Image ARM64
- GitHub Check: Code Coverage
- GitHub Check: test_and_publish
- GitHub Check: UT Tests
- GitHub Check: Analyze (go)
- GitHub Check: Analyze (javascript-typescript)
🔇 Additional comments (2)
src/index.ts (2)
31-32: Logic correctly implements cluster-aware Pyroscope gating.The condition properly disables Pyroscope for the primary process in cluster mode while enabling it for workers and non-cluster deployments:
- Non-cluster mode: Pyroscope enabled (as before)
- Cluster primary: Pyroscope disabled (new behavior)
- Cluster workers: Pyroscope enabled (profiling the processes that handle traffic)
116-116: Correctly updated to use the renamed cluster utility.The call properly uses
clusterUtil.startto match the renamed import, maintaining the existing cluster startup behavior.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## develop #4756 +/- ##
===========================================
+ Coverage 91.91% 91.94% +0.02%
===========================================
Files 651 652 +1
Lines 34613 34630 +17
Branches 8131 8147 +16
===========================================
+ Hits 31816 31840 +24
+ Misses 2548 2541 -7
Partials 249 249 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
Allure Test reports for this run are available at:
|
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (1)
src/index.ts (1)
34-64: Pyroscope initialization correctly gated byenablePyroscope.The conditional initialization at line 34 properly uses the new
enablePyroscopevariable, ensuring Pyroscope is only started when both the server address is configured and the process is not a cluster primary.However, the log message at line 63 should be updated to reflect all reasons Pyroscope might be disabled.
Apply this diff to improve the log message accuracy:
} else { - logger.info('Pyroscope disabled (PYROSCOPE_SERVER_ADDRESS not set)'); + logger.info( + 'Pyroscope disabled' + + (!process.env.PYROSCOPE_SERVER_ADDRESS + ? ' (PYROSCOPE_SERVER_ADDRESS not set)' + : ' (running as primary process in cluster mode)'), + ); }
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
src/index.ts(3 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
src/index.ts (1)
src/util/prometheus.js (1)
clusterEnabled(5-5)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (9)
- GitHub Check: Build Transformer Docker Image - PR / Build Transformer Docker Image ARM64
- GitHub Check: Build Transformer Docker Image - PR / Build Transformer Docker Image AMD64
- GitHub Check: Build User Transformer Docker Image - PR / Build Transformer Docker Image ARM64
- GitHub Check: Build User Transformer Docker Image - PR / Build Transformer Docker Image AMD64
- GitHub Check: Code Coverage
- GitHub Check: UT Tests
- GitHub Check: test_and_publish
- GitHub Check: Analyze (go)
- GitHub Check: Analyze (javascript-typescript)
🔇 Additional comments (3)
src/index.ts (3)
8-8: Import order now complies with ESLint rules.The native
clustermodule import at line 8 now correctly precedes all local imports (including the renamedclusterUtilat line 16). This resolves the pipeline failure mentioned in the previous review.Also applies to: 16-16
31-32: Cluster-aware Pyroscope gating logic is correct.The
enablePyroscopecondition correctly implements the requirement: Pyroscope is disabled on the primary process when clustering is enabled, while remaining enabled for worker processes and for non-clustered deployments.
116-116: Correct usage of renamedclusterUtil.The call to
clusterUtil.start(...)correctly references the renamed local cluster utility import, avoiding the naming conflict with the native Node.jsclustermodule.
|
Allure Test reports for this run are available at:
|
|
* feat: introduce e2e tests UT (#4686) * chore: update slack notification list (#4706) * chore: skip pushing docker images for dependabot (#4714) * chore: skip building images for debendabot * chore: review comments * chore: skip docker login for dependabot * chore: skip docker login for dependabot * chore: misc * chore: misc * chore: misc * chore: misc * chore: review comments * chore: review comments * chore: review comments * chore: review comments * chore: review comments * chore: add dub to new test structure (#4717) * chore: add readme for campaign_manager (#4710) * chore: update GAOC readme with quota link (#4723) * chore: apply security best practices (#4708) [StepSecurity] Apply security best practices Signed-off-by: StepSecurity Bot <[email protected]> * feat: add validation of diff in staging deployment workflow (#4722) * chore(deps-dev): bump commander from 10.0.1 to 14.0.2 Bumps [commander](https://github.com/tj/commander.js) from 10.0.1 to 14.0.2. - [Release notes](https://github.com/tj/commander.js/releases) - [Changelog](https://github.com/tj/commander.js/blob/master/CHANGELOG.md) - [Commits](tj/commander.js@v10.0.1...v14.0.2) --- updated-dependencies: - dependency-name: commander dependency-version: 14.0.2 dependency-type: direct:development update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] <[email protected]> * chore(deps-dev): bump supertest from 6.3.4 to 7.1.4 (#4525) --- updated-dependencies: - dependency-name: supertest dependency-version: 7.1.4 dependency-type: direct:development update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * chore: add env vars for controlling the connection pooling on python transformations (#4738) * chore: update facebook conversion api version from 22.0 to 24.0 (#4734) * chore: update facebook conversion api version from 22.0 to 23.0 * chore: update facebook conversion api version from 23.0 to 45.0 * chore: fix typo * chore: update facebook custom audience api version from 22.0 to 23.0 (#4735) * chore: update facebook custom audience api version from 22.0 to 23.0 * chore: update facebook custom audience api version from 23.0 to 24.0 * chore: update facebook custom audience api version from 24.0 to 23.0 as it has some breaking changes * chore: update facebook pixel api version from 22.0 to 24.0 (#4737) * chore: update facebook pixel api version from 22.0 to 24.0 * chore: update facebook app events api version from 22.0 to 24.0 (#4736) * chore: move rs-ai memory bank to transformer * chore: add nodemon for hot reloading (#4748) * chore: refactor code to update variable name in more readable format (#4747) * feat: source transformation endpoint for facebook_lead_ads_native source (#4746) * chore: disable clustering in nodemon configuration (#4749) * chore: run format check on all files (#4750) * fix: intercom rETL flow when user_id only provided as identifier (#4739) * chore: apply security best practices from step security (#4727) [StepSecurity] Apply security best practices Signed-off-by: StepSecurity Bot <[email protected]> Co-authored-by: stepsecurity-app[bot] <188008098+stepsecurity-app[bot]@users.noreply.github.com> * chore(deps): bump actions/setup-node from 5.0.0 to 6.0.0 Bumps [actions/setup-node](https://github.com/actions/setup-node) from 5.0.0 to 6.0.0. - [Release notes](https://github.com/actions/setup-node/releases) - [Commits](actions/setup-node@v5.0.0...v6.0.0) --- updated-dependencies: - dependency-name: actions/setup-node dependency-version: 6.0.0 dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] <[email protected]> * chore: remove logs logging request/response body (#4754) * chore: disable pyroscope for primary process in cluster mode (#4756) * feat(reddit): onboard v3 api (#4699) * feat(reddit): onboard v3 api * chore: implement router batching flow * feat: enable batching scenario * chore: add test cases * chore: address coderabbit comments * chore: add mock for timestamp * chore: add documentation for reddit * fix: use crypto for hashing * chore: address coderabbit comment * chore: address comments * chore: add validation and remove double type assertion * chore: remove undefined files from final palyload * chore: fix test case * feat(reddit): onboard v3 api * chore: implement router batching flow * feat: enable batching scenario * chore: add test cases * chore: address coderabbit comments * chore: add mock for timestamp * chore: add documentation for reddit * fix: use crypto for hashing * chore: address coderabbit comment * chore: address comments * chore: add validation and remove double type assertion * chore: remove undefined files from final palyload * chore: fix test case * chore: apply format * chore: apply format * chore(deps): bump actions/checkout from 4.3.0 to 5.0.0 Bumps [actions/checkout](https://github.com/actions/checkout) from 4.3.0 to 5.0.0. - [Release notes](https://github.com/actions/checkout/releases) - [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md) - [Commits](actions/checkout@v4.3.0...08c6903) --- updated-dependencies: - dependency-name: actions/checkout dependency-version: 5.0.0 dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] <[email protected]> * feat: add advertiser_tracking_enabled mapping for pinterest without featureFlag (#4740) * chore(deps): bump actions/stale from 10.0.0 to 10.1.0 Bumps [actions/stale](https://github.com/actions/stale) from 10.0.0 to 10.1.0. - [Release notes](https://github.com/actions/stale/releases) - [Changelog](https://github.com/actions/stale/blob/main/CHANGELOG.md) - [Commits](actions/stale@v10.0.0...v10.1.0) --- updated-dependencies: - dependency-name: actions/stale dependency-version: 10.1.0 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <[email protected]> * chore: handle breaking changes for commander * chore: fix breaking commander changes * chore(release): 1.112.0 --------- Signed-off-by: StepSecurity Bot <[email protected]> Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: Rohith BCS <[email protected]> Co-authored-by: Vinay Teki <[email protected]> Co-authored-by: Mahesh Kutty <[email protected]> Co-authored-by: Sudip Paul <[email protected]> Co-authored-by: stepsecurity-app[bot] <188008098+stepsecurity-app[bot]@users.noreply.github.com> Co-authored-by: Krishna Chaitanya <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Jayachand Mopidevi <[email protected]> Co-authored-by: GitHub Actions <[email protected]> Co-authored-by: shekhar-rudder <[email protected]>



Summary
Disables Pyroscope profiling for the primary (master) process when running in cluster mode, while keeping it enabled for worker processes.
Changes
clusterimport toclusterUtilto avoid naming conflict with Node.js nativeclustermoduleclustermodule to checkcluster.isPrimaryMotivation
In cluster mode, the primary process acts as a coordinator and doesn't handle actual requests - only worker processes do. Profiling the primary process provides no useful performance insights and wastes resources. This change ensures Pyroscope only profiles the worker processes that actually handle application traffic.
Any changes to existing capabilities/behaviour, mention the reason & what are the changes ?
N/A
Any new dependencies introduced with this change?
N/A
Any new generic utility introduced or modified. Please explain the changes.
N/A
Any technical or performance related pointers to consider with the change?
N/A
@coderabbitai review
Developer checklist
My code follows the style guidelines of this project
No breaking changes are being introduced.
All related docs linked with the PR?
All changes manually tested?
Any documentation changes needed with this change?
Is the PR limited to 10 file changes?
Is the PR limited to one linear task?
Are relevant unit and component test-cases added in new readability format?
Reviewer checklist
Is the type of change in the PR title appropriate as per the changes?
Verified that there are no credentials or confidential data exposed with the changes.