Skip to content

chore(release): pull main into develop post release v1.107.3 - #4591

Merged
vinayteki95 merged 7 commits into
developfrom
main
Aug 26, 2025
Merged

vinayteki95 merged 7 commits into
developfrom
main

Conversation

@devops-github-rudderstack

Copy link
Copy Markdown
Contributor

👑 An automated PR

@coderabbitai

coderabbitai Bot commented Aug 26, 2025 •

Copy link
Copy Markdown
Contributor

Summary by CodeRabbit

  • New Features

    • Optional runtime profiling integration activated via environment variables; when enabled, it starts automatically with configurable sampling and flush intervals.
    • Clear logging when profiling is disabled.
  • Refactor

    • Switched to a label-based profiling approach to improve observability.
    • Profiling hooks now apply only when profiling is enabled, replacing previous unconditional behavior.
    • Updated public integration points to align with the new profiling approach.

Walkthrough

Introduces conditional Pyroscope profiling initialization in src/index.ts, gated by PYROSCOPE_SERVER_ADDRESS, and applies profiling labels middleware only when initialized. Refactors middleware to export addProfilingLabelsMiddleware using wrapWithLabels. Updates tests to remove Pyroscope mocks and references, retaining duration and request size middleware tests.

Changes

Cohort / File(s) Summary
Profiling initialization and gating
src/index.ts
Adds env-gated Pyroscope setup (appName, serverAddress, flushIntervalMs, heap/wall sampling). Sets a flag when initialized. Applies addProfilingLabelsMiddleware(app) only if initialized. Replaces previous unconditional profiling middleware usage and updates import.
Middleware refactor to label-based profiling
src/middleware.js
Removes direct Pyroscope init. Adds addProfilingLabelsMiddleware that wraps next() with wrapWithLabels, labeling integration_type (source vs destination via URL) and integration_name (via getDestTypeFromContext). Updates exports, replacing addProfilingMiddleware.
Test updates removing Pyroscope
src/middleware.test.js
Deletes Pyroscope mocks and tests. Updates imports to only addStatMiddleware and addRequestSizeMiddleware. Keeps duration and request size middleware tests; no new tests added for label-based profiling.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  actor Env as Environment
  participant Proc as Process Startup
  participant Pyro as Pyroscope
  participant App as Koa App
  participant MW as Middleware

  Note over Proc,App: Application boot
  Proc->>Env: Read PYROSCOPE_SERVER_ADDRESS
  alt Address set
    Proc->>Pyro: initialize(appName, serverAddress, sampling, flushInterval)
    Pyro-->>Proc: initialized
    Proc->>App: addProfilingLabelsMiddleware()
    Note right of App: Middleware labels requests<br/>(integration_type, integration_name)
  else Not set
    Proc-->>App: Skip profiling middleware
    Note right of App: Profiling disabled
  end

  App->>MW: Handle request
  alt Profiling enabled
    MW->>MW: wrapWithLabels({...})
    MW->>App: next()
  else Disabled
    MW->>App: next() (no labels)
  end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested reviewers

  • sivashanmukh
  • vinayteki95
  • koladilip
  • ItsSudip

Suggestions

  • Add unit tests for addProfilingLabelsMiddleware to verify label keys/values for source vs destination paths.
  • Include a log of effective sampling config on init for diagnostics.
  • Guard wrapWithLabels import with a fallback or add error handling if labeling fails to avoid impacting request flow.

Tip

🔌 Remote MCP (Model Context Protocol) integration is now available!

Pro plan users can now connect to remote MCP servers from the Integrations page. Connect with popular remote MCPs such as Notion and Linear to add more context to your reviews and chats.

✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch main

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.
    • 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.
  • 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 the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

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

CodeRabbit Commands (Invoked using PR/Issue comments)

Type @coderabbitai help to get the list of available commands.

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.

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • 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.

@codecov

codecov Bot commented Aug 26, 2025 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 12.50000% with 7 lines in your changes missing coverage. Please review.
✅ Project coverage is 91.79%. Comparing base (67c3fda) to head (e9a4ebd).
⚠️ Report is 16 commits behind head on develop.

Files with missing lines Patch % Lines
src/middleware.js 12.50% 7 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #4591      +/-   ##
===========================================
- Coverage    91.81%   91.79%   -0.03%     
===========================================
  Files          642      642              
  Lines        33926    33928       +2     
  Branches      8030     8040      +10     
===========================================
- Hits         31148    31143       -5     
+ Misses        2548     2533      -15     
- Partials       230      252      +22     

☔ 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 Author

Allure Test reports for this run are available at:

@sonarqubecloud

Copy link
Copy Markdown

@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: 4

🧹 Nitpick comments (2)
src/middleware.js (1)

57-58: Deriving integration_type from URL substring is brittle.

Using url.includes('source') risks misclassification (querystrings, unrelated paths). Consider deriving from matched route or a trusted context property (e.g., router name or ctx.state).

Example tweak (if you can access a normalized path segment):

- integration_type: ctx.request.url.includes('source') ? 'source' : 'destination',
+ integration_type: /^\/sources?\b/.test(ctx.path) ? 'source' : 'destination',
src/middleware.test.js (1)

1-137: Add targeted tests for addProfilingLabelsMiddleware with a mock.

There’s no coverage for the new profiling middleware. Add a focused test that mocks @pyroscope/nodejs and asserts labels are applied with expected values; this remains unit-level and doesn’t require the real SDK.

Sketch:

jest.mock('@pyroscope/nodejs', () => ({
  wrapWithLabels: jest.fn((labels, cb) => cb()),
}));

it('applies profiling labels around request', async () => {
  const { addProfilingLabelsMiddleware } = require('./middleware');
  const { wrapWithLabels } = require('@pyroscope/nodejs');
  const Koa = require('koa');

  const app = new Koa();
  addProfilingLabelsMiddleware(app);
  app.use(async (ctx) => { ctx.status = 204; });

  await request(app.callback()).get('/v1/destinations/foo'); // adjust path as needed

  expect(wrapWithLabels).toHaveBeenCalledWith(
    expect.objectContaining({
      integration_type: 'destination',
      integration_name: expect.any(String),
    }),
    expect.any(Function)
  );
});
📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between cc893c3 and e9a4ebd.

⛔ Files ignored due to path filters (3)
  • CHANGELOG.md is excluded by !**/*.md
  • package-lock.json is excluded by !**/package-lock.json, !**/*.json
  • package.json is excluded by !**/*.json
📒 Files selected for processing (3)
  • src/index.ts (3 hunks)
  • src/middleware.js (2 hunks)
  • src/middleware.test.js (1 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
**/*.js

⚙️ CodeRabbit configuration file

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

Files:

  • src/middleware.js
  • src/middleware.test.js
🧠 Learnings (1)
📚 Learning: 2025-08-26T09:02:38.628Z
Learnt from: vinayteki95
PR: rudderlabs/rudder-transformer#4578
File: src/middleware.js:52-66
Timestamp: 2025-08-26T09:02:38.628Z
Learning: The pyroscope/nodejs wrapWithLabels function does not return anything (void function). It executes its callback synchronously to establish a labeled context for profiling data collection, but the return value of the callback is not returned by wrapWithLabels itself.

Applied to files:

  • src/middleware.js
🧬 Code graph analysis (1)
src/index.ts (1)
src/logger.js (7)
  • logger (9-21)
  • logger (33-33)
  • logger (119-119)
  • logger (126-126)
  • logger (133-133)
  • logger (140-140)
  • logger (147-147)
⏰ 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). (6)
  • GitHub Check: Code Coverage
  • GitHub Check: UT Tests
  • GitHub Check: test_and_publish
  • GitHub Check: Analyze (javascript-typescript)
  • GitHub Check: Analyze (go)
  • GitHub Check: Analyze (javascript-typescript)
🔇 Additional comments (4)
src/middleware.js (1)

71-71: Export name alignment looks good.

Exporting addProfilingLabelsMiddleware matches the new API and index.ts usage.

src/middleware.test.js (1)

4-4: Import updates are consistent with the current public API.

Dropping addProfilingMiddleware from tests aligns with the new exports.

src/index.ts (2)

92-95: Conditional application of profiling labels is correct.

Nice guard; we’ll only incur profiling overhead when initialized.


1-177: No stale profiling middleware references found, manual dependency check needed

I ran a search across src/**/*.ts/js and confirmed there are no remaining calls to the old addProfilingMiddleware API. However, I wasn’t able to locate a package.json in the repository to verify that @pyroscope/nodejs is declared under dependencies (or devDependencies).

• Verified no references to addProfilingMiddleware.
• Could not find a package.json—please ensure you’re looking in the correct directory and confirm that @pyroscope/nodejs is listed as a dependency.

Comment thread src/index.ts Resolved
Comment thread src/index.ts Resolved
Comment thread src/middleware.js Resolved
Comment thread src/middleware.js Resolved
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.

4 participants