Skip to content

fix: pyroscope memory and wall prof - #4519

Merged
koladilip merged 2 commits into
release/v1.105.0from
chore.pyroscope-memory-prof
Jul 22, 2025
Merged

koladilip merged 2 commits into
release/v1.105.0from
chore.pyroscope-memory-prof

Conversation

@vinayteki95

Copy link
Copy Markdown
Contributor

What are the changes introduced in this PR?

Improved Pyroscope instrumentation to capture wall, cpu and memory profiling data with default configurations. Profiling configurations can be controlled via new ENV variables.

  • PYROSCOPE_WALL_SAMPLING_DURATION_MS
  • PYROSCOPE_WALL_SAMPLING_INTERVAL_MICROS
  • PYROSCOPE_HEAP_SAMPLING_INTERVAL_BYTES
  • PYROSCOPE_HEAP_STACK_DEPTH

What is the related Linear task?

Resolves INT-3895

Please explain the objectives of your changes below

Pyroscope memory utilisation has been missing for a long time. This has been a need for observability team as well as integrations team to debug memory intensive components in transformer. Especially to debug memory based crashes and errors in transformer.

Any changes to existing capabilities/behaviour, mention the reason & what are the changes ?

Memory profiling for transformer via new configurations

Any new dependencies introduced with this change?

No

Any new generic utility introduced or modified. Please explain the changes.

New ENVs introduced.

Any technical or performance related pointers to consider with the change?

Memory profiling might put some extra load on the transformer. This has to be seen live to understand the effects of it.

@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.

@vinayteki95
vinayteki95 requested a review from a team July 22, 2025 10:37
@coderabbitai

coderabbitai Bot commented Jul 22, 2025 •

Copy link
Copy Markdown
Contributor

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Summary by CodeRabbit

  • New Features
    • Added configurable environment-based settings for profiling parameters, allowing customization of sampling durations, intervals, and stack depth.
  • Bug Fixes
    • Improved profiling initialization to ensure all relevant parameters are explicitly set and profiling is reliably activated.
  • Tests
    • Enhanced tests to verify correct configuration and initialization of profiling with the new parameters.

Walkthrough

The changes introduce environment-driven constants for Pyroscope profiling parameters, update the Pyroscope initialization to explicitly include wall and heap profiling configurations, and ensure profiling activation with Pyroscope.start(). The new constants are exported for external use, and corresponding tests are updated to validate the expanded configuration and exports.

Changes

File(s) Change Summary
src/middleware.js Added and exported environment-driven constants for Pyroscope profiling; updated Pyroscope initialization; added Pyroscope.start() call; omitted serverAddress for pull mode.
src/middleware.test.js Imported new constants; extended Pyroscope mock; enhanced tests to verify expanded profiling configuration and exports.

Sequence Diagram(s)

sequenceDiagram
    participant App as Application
    participant MW as Middleware
    participant Pyro as Pyroscope

    App->>MW: Import and configure middleware
    MW->>Pyro: Pyroscope.init({ wallConfig, heapConfig, ... })
    MW->>Pyro: Pyroscope.start()
    App->>MW: Use exported profiling constants
Loading

Estimated code review effort

2 (~15 minutes)

Possibly related PRs

  • chore: enable collection of cpu data #4267: Both PRs modify the Pyroscope initialization in src/middleware.js, with this PR expanding profiling parameters and the related PR enabling CPU time collection under wall profiling.

Suggested reviewers

  • sivashanmukh
  • yashasvibajpai

Suggestions for improvement:

  • Consider adding validation or fallback logic for the environment variable parsing to prevent misconfiguration.
  • Expand test coverage for edge cases, such as missing or malformed environment variables.
  • Document the purpose and recommended values for the new constants in a README or code comments for easier maintainability.

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.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@vinayteki95
vinayteki95 changed the base branch from develop to release/v1.105.0 July 22, 2025 10:38

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between b105b72 and c1f088c.

📒 Files selected for processing (2)
  • src/middleware.js (2 hunks)
  • src/middleware.test.js (3 hunks)
📓 Path-based instructions (1)
**/*.js

⚙️ CodeRabbit Configuration File

Focus on ESLint errors (max 3) and warnings (max 5).

Files:

  • src/middleware.test.js
  • src/middleware.js
🧰 Additional context used
📓 Path-based instructions (1)
**/*.js

⚙️ CodeRabbit Configuration File

Focus on ESLint errors (max 3) and warnings (max 5).

Files:

  • src/middleware.test.js
  • src/middleware.js
⏰ 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). (8)
  • GitHub Check: Build Transformer Docker Image - PR / Build Transformer Docker Image AMD64
  • GitHub Check: Build User Transformer Docker Image - PR / Build Transformer Docker Image AMD64
  • GitHub Check: Build User Transformer Docker Image - PR / Build Transformer Docker Image ARM64
  • GitHub Check: Code Coverage
  • GitHub Check: UT Tests
  • GitHub Check: test_and_publish
  • GitHub Check: Analyze (javascript-typescript)
  • GitHub Check: Analyze (go)
🔇 Additional comments (4)
src/middleware.js (2)

22-37: Excellent Pyroscope configuration implementation.

The configuration properly enables comprehensive profiling with well-documented parameters. The omission of serverAddress for pull mode and the explicit Pyroscope.start() call correctly implement the requirements for Grafana Agent scraping.


93-96: Good addition of constant exports.

The new constants are properly exported, enabling external access for testing and configuration verification.

src/middleware.test.js (2)

8-11: Proper test setup for new constants and mock.

The imports correctly include all new profiling constants, and the Pyroscope mock properly includes the start method to match the actual implementation.

Also applies to: 22-22


38-50: Comprehensive test coverage for updated Pyroscope configuration.

The test properly verifies that Pyroscope.init is called with the complete configuration object, including all new wall and heap profiling parameters. Using the imported constants ensures accurate validation of the actual configuration values.

Comment thread src/middleware.js Resolved
@devops-github-rudderstack

Copy link
Copy Markdown
Contributor

Allure Test reports for this run are available at:

@codecov

codecov Bot commented Jul 22, 2025 •

Copy link
Copy Markdown

Codecov Report

All modified and coverable lines are covered by tests ✅

Please upload report for BASE (release/v1.105.0@b105b72). Learn more about missing BASE report.

Additional details and impacted files
@@                 Coverage Diff                 @@
##             release/v1.105.0    #4519   +/-   ##
===================================================
  Coverage                    ?   91.44%           
===================================================
  Files                       ?      639           
  Lines                       ?    33786           
  Branches                    ?     7982           
===================================================
  Hits                        ?    30897           
  Misses                      ?     2655           
  Partials                    ?      234           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@devops-github-rudderstack

Copy link
Copy Markdown
Contributor

Allure Test reports for this run are available at:

@koladilip
koladilip merged commit 1df0e6e into release/v1.105.0 Jul 22, 2025
@koladilip
koladilip deleted the chore.pyroscope-memory-prof branch July 22, 2025 11:53
@sonarqubecloud

Copy link
Copy Markdown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants