Skip to content

chore(release): pull main into develop post release v1.105.0 - #4520

Merged
koladilip merged 6 commits into
developfrom
main
Jul 23, 2025
Merged

koladilip merged 6 commits into
developfrom
main

Conversation

@devops-github-rudderstack

Copy link
Copy Markdown
Contributor

👑 An automated PR

@coderabbitai

coderabbitai Bot commented Jul 22, 2025 •

Copy link
Copy Markdown
Contributor

Summary by CodeRabbit

  • New Features
    • Enhanced configuration options for profiling, allowing more precise control through environment variables.
  • Bug Fixes
    • Improved error tracking by explicitly recording detailed error information in statistics and monitoring.
  • Tests
    • Expanded test coverage for environment variable parsing and profiling configuration.
  • Refactor
    • Standardized the way error details are passed to statistics tracking for better consistency.
  • Chores
    • Added new labels to monitoring metrics for more granular error categorization.

Walkthrough

This change introduces a utility for safe integer environment variable parsing and applies it to configure Pyroscope profiling parameters. Pyroscope initialization is updated to use these parameters explicitly. Error statistics tracking is refined to pass selected error fields instead of whole objects. Prometheus counters gain two new error-related labels. Associated tests are expanded.

Changes

File(s) Change Summary
src/middleware.js Adds parseEnvInt utility, new Pyroscope config constants, updates Pyroscope initialization and export logic.
src/middleware.test.js Adds/updates tests for parseEnvInt and Pyroscope config, mocks Pyroscope start, covers edge cases in parsing.
src/services/destination/cdkV2Integration.ts
src/services/destination/postTransformation.ts
Refines stats.increment calls to pass explicit error fields instead of entire errorDetails objects.
src/util/prometheus.js Adds errorCategory and errorType labels to event_transform_failure and regulation_worker_user_deletion_failure counters.

Sequence Diagram(s)

sequenceDiagram
    participant Env as process.env
    participant MW as middleware.js
    participant Pyro as Pyroscope

    Env->>MW: Provide environment variables
    MW->>MW: parseEnvInt for each Pyroscope config param
    MW->>Pyro: Initialize Pyroscope with explicit params
    MW->>Pyro: Pyroscope.start()
Loading
sequenceDiagram
    participant Service as Service
    participant Stats as stats.increment

    Service->>Stats: increment({ destType, module, destinationId, workspaceId, feature, implementation, errorCategory, errorType })
Loading

Estimated code review effort

3 (~40 minutes)

Possibly related PRs

  • fix: pyroscope memory and wall prof #4519: Both PRs modify src/middleware.js to introduce environment-configurable Pyroscope profiling parameters and update Pyroscope initialization, indicating a direct code-level relationship.

Suggested reviewers

  • sivashanmukh
  • koladilip
  • krishna2020
  • manish339k
  • sandeepdsvs

Suggestions for improvement:

  • Consider centralizing error field extraction logic to avoid repetition.
  • Add documentation for new environment variables and their intended usage.
  • Ensure Prometheus label cardinality is monitored to prevent metric explosion.
✨ Finishing Touches
  • 📝 Generate Docstrings

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.

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

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

206-206: Optimize delete operator for better performance.

The static analysis tool correctly identified that the delete operator can impact performance. Use an undefined assignment instead.

Apply this change:

-      delete process.env.TEST_VAR;
+      process.env.TEST_VAR = undefined;
📜 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 bf8007e.

⛔ 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 (5)
  • src/middleware.js (2 hunks)
  • src/middleware.test.js (4 hunks)
  • src/services/destination/cdkV2Integration.ts (1 hunks)
  • src/services/destination/postTransformation.ts (3 hunks)
  • src/util/prometheus.js (2 hunks)
📓 Path-based instructions (1)
**/*.js

⚙️ CodeRabbit Configuration File

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

Files:

  • src/util/prometheus.js
  • src/middleware.js
  • src/middleware.test.js
🧠 Learnings (3)
src/services/destination/cdkV2Integration.ts (6)

Learnt from: maheshkutty
PR: #4359
File: src/v0/util/index.js:2272-2272
Timestamp: 2025-05-29T13:29:39.436Z
Learning: The combineBatchRequestsWithSameJobIds function in src/v0/util/index.js is used by both Mixpanel and Google AdWords Offline Conversions destinations in production. The function assumes metadata is always an array in multiple operations (forEach, filter, sort, map) and needs defensive programming to handle non-array metadata cases to prevent runtime errors.

Learnt from: vinayteki95
PR: #4220
File: src/middlewares/routerTransformCompactedPayloadV1.ts:13-24
Timestamp: 2025-04-02T08:21:38.217Z
Learning: In the Rudder Transformer codebase, use generic Error objects instead of TransformationError when error monitoring with Bugsnag is needed, as TransformationError is configured to not trigger Bugsnag alerts.

Learnt from: maheshkutty
PR: #4359
File: src/v0/util/index.js:2272-2272
Timestamp: 2025-05-29T13:29:39.436Z
Learning: The combineBatchRequestsWithSameJobIds function in src/v0/util/index.js assumes metadata is always an array throughout its implementation, but defensive programming should be added to handle cases where metadata might not be an array type to prevent runtime errors.

Learnt from: ItsSudip
PR: #4186
File: src/middlewares/arraySpreader.ts:48-63
Timestamp: 2025-04-08T02:59:55.677Z
Learning: In the ArraySpreader/BaseSpreader middleware, error handling for the transform function is already implemented in the caller (BaseSpreader's middleware method), making additional error handling in individual transform functions unnecessary.

Learnt from: vinayteki95
PR: #4220
File: src/middlewares/destTransformCompactedPayloadV1.ts:13-19
Timestamp: 2025-04-02T08:16:58.002Z
Learning: In the Rudder Transformer project, error handling should throw errors with descriptive messages (after logging them) rather than returning HTTP status codes, so that Bugsnag can catch them for debugging purposes.

Learnt from: ItsSudip
PR: #4186
File: src/middlewares/arraySpreader.ts:48-63
Timestamp: 2025-04-08T02:59:55.677Z
Learning: In the BaseSpreader middleware implementation, error handling for transform functions is already handled in the middleware() method with a try-catch block, which wraps errors in a PlatformError. This makes additional error handling inside individual transform functions unnecessary.

src/services/destination/postTransformation.ts (8)

Learnt from: vinayteki95
PR: #4220
File: src/middlewares/routerTransformCompactedPayloadV1.ts:13-24
Timestamp: 2025-04-02T08:21:38.217Z
Learning: In the Rudder Transformer codebase, use generic Error objects instead of TransformationError when error monitoring with Bugsnag is needed, as TransformationError is configured to not trigger Bugsnag alerts.

Learnt from: maheshkutty
PR: #4359
File: src/v0/util/index.js:2272-2272
Timestamp: 2025-05-29T13:29:39.436Z
Learning: The combineBatchRequestsWithSameJobIds function in src/v0/util/index.js is used by both Mixpanel and Google AdWords Offline Conversions destinations in production. The function assumes metadata is always an array in multiple operations (forEach, filter, sort, map) and needs defensive programming to handle non-array metadata cases to prevent runtime errors.

Learnt from: ItsSudip
PR: #4497
File: src/v0/destinations/tiktok_ads/transformV2.js:686-691
Timestamp: 2025-07-15T06:27:07.528Z
Learning: For TikTok Ads destination in src/v0/destinations/tiktok_ads/transformV2.js, there are plans for a future enhancement to group events by eventSource when batching to ensure all events in a batch have the same event_source value, as acknowledged by ItsSudip in PR #4497.

Learnt from: ItsSudip
PR: #4186
File: src/middlewares/arraySpreader.ts:48-63
Timestamp: 2025-04-08T02:59:55.677Z
Learning: In the ArraySpreader/BaseSpreader middleware, error handling for the transform function is already implemented in the caller (BaseSpreader's middleware method), making additional error handling in individual transform functions unnecessary.

Learnt from: vinayteki95
PR: #4220
File: src/middlewares/destTransformCompactedPayloadV1.ts:13-19
Timestamp: 2025-04-02T08:16:58.002Z
Learning: In the Rudder Transformer project, error handling should throw errors with descriptive messages (after logging them) rather than returning HTTP status codes, so that Bugsnag can catch them for debugging purposes.

Learnt from: ItsSudip
PR: #4186
File: src/middlewares/arraySpreader.ts:48-63
Timestamp: 2025-04-08T02:59:55.677Z
Learning: In the BaseSpreader middleware implementation, error handling for transform functions is already handled in the middleware() method with a try-catch block, which wraps errors in a PlatformError. This makes additional error handling inside individual transform functions unnecessary.

Learnt from: anantjain45823
PR: #2884
File: src/services/destination/nativeIntegration.ts:207-207
Timestamp: 2024-07-27T07:02:57.329Z
Learning: The startTime variable is correctly scoped within the map callback function in the processUserDeletion method, ensuring individual timing metrics for each user deletion request.

Learnt from: anantjain45823
PR: #2884
File: src/services/destination/nativeIntegration.ts:207-207
Timestamp: 2024-10-08T15:52:59.819Z
Learning: The startTime variable is correctly scoped within the map callback function in the processUserDeletion method, ensuring individual timing metrics for each user deletion request.

src/middleware.test.js (1)

Learnt from: anantjain45823
PR: #2842
File: src/v1/sources/shopify/identifierEventsLayer.test.js:5-40
Timestamp: 2024-07-27T07:02:57.329Z
Learning: The processIdentifierEvent function in identifierEventsLayer.test.js is designed to succeed for any input, hence no negative test cases are required.

🪛 Biome (1.9.4)
src/middleware.test.js

[error] 206-206: Avoid the delete operator which can impact performance.

Unsafe fix: Use an undefined assignment instead.

(lint/performance/noDelete)

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

⚙️ CodeRabbit Configuration File

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

Files:

  • src/util/prometheus.js
  • src/middleware.js
  • src/middleware.test.js
🧠 Learnings (3)
src/services/destination/cdkV2Integration.ts (6)

Learnt from: maheshkutty
PR: #4359
File: src/v0/util/index.js:2272-2272
Timestamp: 2025-05-29T13:29:39.436Z
Learning: The combineBatchRequestsWithSameJobIds function in src/v0/util/index.js is used by both Mixpanel and Google AdWords Offline Conversions destinations in production. The function assumes metadata is always an array in multiple operations (forEach, filter, sort, map) and needs defensive programming to handle non-array metadata cases to prevent runtime errors.

Learnt from: vinayteki95
PR: #4220
File: src/middlewares/routerTransformCompactedPayloadV1.ts:13-24
Timestamp: 2025-04-02T08:21:38.217Z
Learning: In the Rudder Transformer codebase, use generic Error objects instead of TransformationError when error monitoring with Bugsnag is needed, as TransformationError is configured to not trigger Bugsnag alerts.

Learnt from: maheshkutty
PR: #4359
File: src/v0/util/index.js:2272-2272
Timestamp: 2025-05-29T13:29:39.436Z
Learning: The combineBatchRequestsWithSameJobIds function in src/v0/util/index.js assumes metadata is always an array throughout its implementation, but defensive programming should be added to handle cases where metadata might not be an array type to prevent runtime errors.

Learnt from: ItsSudip
PR: #4186
File: src/middlewares/arraySpreader.ts:48-63
Timestamp: 2025-04-08T02:59:55.677Z
Learning: In the ArraySpreader/BaseSpreader middleware, error handling for the transform function is already implemented in the caller (BaseSpreader's middleware method), making additional error handling in individual transform functions unnecessary.

Learnt from: vinayteki95
PR: #4220
File: src/middlewares/destTransformCompactedPayloadV1.ts:13-19
Timestamp: 2025-04-02T08:16:58.002Z
Learning: In the Rudder Transformer project, error handling should throw errors with descriptive messages (after logging them) rather than returning HTTP status codes, so that Bugsnag can catch them for debugging purposes.

Learnt from: ItsSudip
PR: #4186
File: src/middlewares/arraySpreader.ts:48-63
Timestamp: 2025-04-08T02:59:55.677Z
Learning: In the BaseSpreader middleware implementation, error handling for transform functions is already handled in the middleware() method with a try-catch block, which wraps errors in a PlatformError. This makes additional error handling inside individual transform functions unnecessary.

src/services/destination/postTransformation.ts (8)

Learnt from: vinayteki95
PR: #4220
File: src/middlewares/routerTransformCompactedPayloadV1.ts:13-24
Timestamp: 2025-04-02T08:21:38.217Z
Learning: In the Rudder Transformer codebase, use generic Error objects instead of TransformationError when error monitoring with Bugsnag is needed, as TransformationError is configured to not trigger Bugsnag alerts.

Learnt from: maheshkutty
PR: #4359
File: src/v0/util/index.js:2272-2272
Timestamp: 2025-05-29T13:29:39.436Z
Learning: The combineBatchRequestsWithSameJobIds function in src/v0/util/index.js is used by both Mixpanel and Google AdWords Offline Conversions destinations in production. The function assumes metadata is always an array in multiple operations (forEach, filter, sort, map) and needs defensive programming to handle non-array metadata cases to prevent runtime errors.

Learnt from: ItsSudip
PR: #4497
File: src/v0/destinations/tiktok_ads/transformV2.js:686-691
Timestamp: 2025-07-15T06:27:07.528Z
Learning: For TikTok Ads destination in src/v0/destinations/tiktok_ads/transformV2.js, there are plans for a future enhancement to group events by eventSource when batching to ensure all events in a batch have the same event_source value, as acknowledged by ItsSudip in PR #4497.

Learnt from: ItsSudip
PR: #4186
File: src/middlewares/arraySpreader.ts:48-63
Timestamp: 2025-04-08T02:59:55.677Z
Learning: In the ArraySpreader/BaseSpreader middleware, error handling for the transform function is already implemented in the caller (BaseSpreader's middleware method), making additional error handling in individual transform functions unnecessary.

Learnt from: vinayteki95
PR: #4220
File: src/middlewares/destTransformCompactedPayloadV1.ts:13-19
Timestamp: 2025-04-02T08:16:58.002Z
Learning: In the Rudder Transformer project, error handling should throw errors with descriptive messages (after logging them) rather than returning HTTP status codes, so that Bugsnag can catch them for debugging purposes.

Learnt from: ItsSudip
PR: #4186
File: src/middlewares/arraySpreader.ts:48-63
Timestamp: 2025-04-08T02:59:55.677Z
Learning: In the BaseSpreader middleware implementation, error handling for transform functions is already handled in the middleware() method with a try-catch block, which wraps errors in a PlatformError. This makes additional error handling inside individual transform functions unnecessary.

Learnt from: anantjain45823
PR: #2884
File: src/services/destination/nativeIntegration.ts:207-207
Timestamp: 2024-07-27T07:02:57.329Z
Learning: The startTime variable is correctly scoped within the map callback function in the processUserDeletion method, ensuring individual timing metrics for each user deletion request.

Learnt from: anantjain45823
PR: #2884
File: src/services/destination/nativeIntegration.ts:207-207
Timestamp: 2024-10-08T15:52:59.819Z
Learning: The startTime variable is correctly scoped within the map callback function in the processUserDeletion method, ensuring individual timing metrics for each user deletion request.

src/middleware.test.js (1)

Learnt from: anantjain45823
PR: #2842
File: src/v1/sources/shopify/identifierEventsLayer.test.js:5-40
Timestamp: 2024-07-27T07:02:57.329Z
Learning: The processIdentifierEvent function in identifierEventsLayer.test.js is designed to succeed for any input, hence no negative test cases are required.

🪛 Biome (1.9.4)
src/middleware.test.js

[error] 206-206: Avoid the delete operator which can impact performance.

Unsafe fix: Use an undefined assignment instead.

(lint/performance/noDelete)

⏰ 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: test_and_publish
  • GitHub Check: UT Tests
  • GitHub Check: Analyze (javascript-typescript)
  • GitHub Check: Analyze (go)
  • GitHub Check: Analyze (javascript-typescript)
🔇 Additional comments (15)
src/util/prometheus.js (2)

265-266: LGTM: Enhanced error tracking granularity

The addition of errorCategory and errorType labels to the event_transform_failure counter will provide better observability and debugging capabilities for transformation failures.


394-402: LGTM: Consistent label additions with improved formatting

The addition of errorCategory and errorType labels to the regulation_worker_user_deletion_failure counter maintains consistency with the event_transform_failure metric. The reformatting of the labelNames array also improves readability.

src/services/destination/cdkV2Integration.ts (1)

101-110: LGTM: Explicit error detail passing improves consistency

The change from passing the entire metaTo.errorDetails object to explicitly enumerating each property ensures better control over what data is sent to the metrics system. This aligns perfectly with the new errorCategory and errorType labels added to the Prometheus event_transform_failure counter.

src/services/destination/postTransformation.ts (3)

111-120: LGTM: Consistent explicit error detail passing

The modification to explicitly pass individual error detail properties instead of the entire metaTo.errorDetails object maintains consistency with similar changes across the codebase and aligns with the enhanced Prometheus metric labels.


149-159: LGTM: Proper error tracking alignment

The explicit enumeration of error detail properties for the event_transform_failure metric ensures consistent data structure and aligns with the updated Prometheus metric definition that includes errorCategory and errorType labels.


238-247: LGTM: User deletion error tracking enhancement

The change to explicitly pass error detail properties for the regulation_worker_user_deletion_failure metric is consistent with the pattern applied throughout the codebase and properly leverages the new errorCategory and errorType labels added to the corresponding Prometheus counter.

src/middleware.js (5)

6-15: Well-implemented environment variable parsing utility.

The parseEnvInt function properly handles edge cases including undefined values, empty strings, whitespace, and non-integer inputs. The use of Number.isInteger() ensures only valid integers are returned, with fallback to defaults for invalid inputs.


17-29: Appropriate default values for Pyroscope profiling parameters.

The constants use sensible defaults: 60-second sampling duration, 10ms sampling interval, 512KB heap sampling interval, and 64 stack depth. These values provide good balance between profiling detail and performance impact.


31-43: Enhanced Pyroscope configuration with proper parameterization.

The initialization now includes explicit wall and heap profiling parameters, making the profiling behavior configurable through environment variables. The pull mode comment clearly explains the serverAddress omission for Grafana Agent integration.


45-46: Essential Pyroscope.start() call added.

The explicit Pyroscope.start() call is required to activate profiling after initialization. The comment clearly indicates this requirement.


102-106: Appropriate exports for testing and reusability.

The new exports enable comprehensive testing of the environment variable parsing utility and Pyroscope configuration constants.

src/middleware.test.js (4)

8-12: Necessary imports for testing new functionality.

The imported constants and parseEnvInt function are properly utilized in the expanded test suite.


23-23: Required mock update for Pyroscope.start() method.

The mock properly includes the start method that's now called in the main module.


42-49: Comprehensive validation of Pyroscope configuration parameters.

The test now properly verifies that all wall and heap profiling parameters are correctly passed to the Pyroscope initialization, ensuring the environment variable configuration works as expected.


192-277: Comprehensive test suite with excellent coverage.

The parseEnvInt test suite thoroughly covers all edge cases including undefined values, empty strings, whitespace, valid/invalid inputs, and different data types. The environment variable isolation is properly implemented.

@devops-github-rudderstack

Copy link
Copy Markdown
Contributor Author

Allure Test reports for this run are available at:

@codecov

codecov Bot commented Jul 22, 2025 •

Copy link
Copy Markdown

Codecov Report

Attention: Patch coverage is 99.49239% with 1 line in your changes missing coverage. Please review.

Project coverage is 91.44%. Comparing base (f785edf) to head (bf8007e).
Report is 72 commits behind head on develop.

Files with missing lines Patch % Lines
src/v0/destinations/googlesheets/transform.js 91.66% 1 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff            @@
##           develop    #4520   +/-   ##
========================================
  Coverage    91.44%   91.44%           
========================================
  Files          639      639           
  Lines        33772    33786   +14     
  Branches      7983     7989    +6     
========================================
+ Hits         30884    30897   +13     
- Misses        2626     2627    +1     
  Partials       262      262           

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

@sonarqubecloud

Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed

Failed conditions
17.3% Duplication on New Code (required ��� 15%)

See analysis details on SonarQube Cloud

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.

6 participants