Repository navigation
chore(release): pull main into develop post release v1.107.3 - #4591
Conversation
Summary by CodeRabbit
WalkthroughIntroduces 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
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
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Suggested reviewers
Suggestions
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 unit tests
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. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. CodeRabbit Commands (Invoked using PR/Issue comments)Type Other keywords and placeholders
Status, Documentation and Community
|
Codecov Report❌ Patch coverage is
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. 🚀 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: 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.
⛔ Files ignored due to path filters (3)
CHANGELOG.mdis excluded by!**/*.mdpackage-lock.jsonis excluded by!**/package-lock.json,!**/*.jsonpackage.jsonis 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.jssrc/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 neededI ran a search across
src/**/*.ts/jsand confirmed there are no remaining calls to the oldaddProfilingMiddlewareAPI. However, I wasn’t able to locate apackage.jsonin the repository to verify that@pyroscope/nodejsis declared underdependencies(ordevDependencies).• Verified no references to
addProfilingMiddleware.
• Could not find apackage.json—please ensure you’re looking in the correct directory and confirm that@pyroscope/nodejsis listed as a dependency.



👑 An automated PR