Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: Add spans attributes for no of lines and action count #37001

Merged
merged 7 commits into from
Oct 22, 2024

Conversation

rishabhrathod01
Copy link
Contributor

@rishabhrathod01 rishabhrathod01 commented Oct 21, 2024

Description

Fixes #36995

Automation

/ok-to-test tags="@tag.Sanity"

🔍 Cypress test results

Tip

🟢 🟢 🟢 All cypress tests have passed! 🎉 🎉 🎉
Workflow run: https://github.com/appsmithorg/appsmith/actions/runs/11455841055
Commit: 7285f3f
Cypress dashboard.
Tags: @tag.Sanity
Spec:


Tue, 22 Oct 2024 08:35:48 UTC

Communication

Should the DevRel and Marketing teams inform users about this change?

  • Yes
  • No

Summary by CodeRabbit

  • New Features
    • Added new constants for layout operations and data extraction to improve functionality.
    • Introduced observability tracking for various methods to enhance monitoring and performance insights.
  • Bug Fixes
    • Enhanced error handling and logging for action updates and layout modifications.
  • Refactor
    • Improved clarity and maintainability of methods related to action collections and layout updates.
  • Chores
    • Updated method signatures to include new observability parameters for better tracking.
    • Added metrics for line and action counts in action collection updates.

@github-actions github-actions bot added skip-changelog Adding this label to a PR prevents it from being listed in the changelog Javascript Product Issues related to users writing javascript in appsmith JS Objects Issues related to JS Objects Query & JS Pod Issues related to the query & JS Pod Task A simple Todo labels Oct 21, 2024
@rishabhrathod01 rishabhrathod01 added the ok-to-test Required label for CI label Oct 21, 2024
@NilanshBansal NilanshBansal self-requested a review October 22, 2024 06:04
@NilanshBansal
Copy link
Contributor

@rishabhrathod01 can you please resolve merge conflicts and this comment, rest LGTM!

Copy link
Contributor

coderabbitai bot commented Oct 22, 2024

Walkthrough

A new Java class OnLoadSpan has been added, extending OnLoadSpanCE, without introducing new functionality. The LayoutSpanCE class has received two new constants for layout operations. The OnLoadSpanCE class has been introduced with multiple constants for executable operations. Modifications have been made to various service classes, enhancing observability and error handling, particularly in layout updates and on-load executable management. These changes aim to improve performance monitoring and tracking within the application.

Changes

File Change Summary
app/server/appsmith-interfaces/src/main/java/com/appsmith/external/constants/spans/OnLoadSpan.java Added new class OnLoadSpan extending OnLoadSpanCE.
app/server/appsmith-interfaces/src/main/java/com/appsmith/external/constants/spans/ce/LayoutSpanCE.java Added constants UNESCAPE_MONGO_SPECIAL_CHARS and EXTRACT_ALL_WIDGET_NAMES_AND_DYNAMIC_BINDINGS_FROM_DSL.
app/server/appsmith-interfaces/src/main/java/com/appsmith/external/constants/spans/ce/OnLoadSpanCE.java Introduced class OnLoadSpanCE with multiple constants for executable operations.
app/server/appsmith-server/src/main/java/com/appsmith/server/layouts/UpdateLayoutServiceCEImpl.java Enhanced layout update functionality with observability features and improved error handling.
app/server/appsmith-server/src/main/java/com/appsmith/server/layouts/UpdateLayoutServiceImpl.java Modified constructor to include ObservationHelperImpl for enhanced observation handling.
app/server/appsmith-server/src/main/java/com/appsmith/server/onload/internal/OnLoadExecutablesUtilCEImpl.java Improved observability in methods related to on-load executables management.
app/server/appsmith-server/src/main/java/com/appsmith/server/services/ce/LayoutActionServiceCEImpl.java Updated methods for action handling with enhanced observability and error handling.
app/server/appsmith-server/src/main/java/com/appsmith/server/services/ce/LayoutCollectionServiceCEImpl.java Enhanced updateUnpublishedActionCollection method with metrics for better observability.

Assessment against linked issues

Objective Addressed Explanation
Add metrics for updatePageLayoutsByPageId and related methods (#36995)
Add metrics for unescapeMongoSpecialCharacters (#36995)
Add metrics for extractAllWidgetNamesAndDynamicBindingsFromDSL (#36995)
Add metrics for getAllExecutablesByCreatorIdFlux (#36995)
Add metrics for addExplicitUserSetOnLoadExecutablesToGraph and related methods (#36995) Not all relevant methods were updated with metrics.

Possibly related PRs

Suggested labels

Integrations Product, Integrations Pod General, Test, Widgets & Accelerators Pod

Suggested reviewers

  • ApekshaBhosale
  • sneha122

🌟 In the code's embrace, new spans take flight,
Observability shines, making errors less tight.
With constants and classes, the layout's refined,
Tracking each action, with metrics aligned.
From executables to layouts, the changes are clear,
In the realm of Java, we celebrate here! 🎉


📜 Recent review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between a444f5f and 7285f3f.

📒 Files selected for processing (1)
  • app/server/appsmith-server/src/main/java/com/appsmith/server/onload/internal/OnLoadExecutablesUtilCEImpl.java (13 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • app/server/appsmith-server/src/main/java/com/appsmith/server/onload/internal/OnLoadExecutablesUtilCEImpl.java

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ 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.
    • Generate unit testing code for this file.
    • 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 generate unit testing code for this file.
    • @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 generate unit testing code.
    • @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.

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

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 9

🧹 Outside diff range and nitpick comments (4)
app/server/appsmith-interfaces/src/main/java/com/appsmith/external/constants/spans/ce/LayoutSpanCE.java (1)

18-20: LGTM. Consider line breaks for readability.

The new constants are well-defined and consistent with the existing pattern. For improved readability, consider breaking the longer constant definition into multiple lines:

public static final String EXTRACT_ALL_WIDGET_NAMES_AND_DYNAMIC_BINDINGS_FROM_DSL =
        APPSMITH_SPAN_PREFIX + "extractAllWidgetNamesAndDynamicBindingsFromDSL";
app/server/appsmith-server/src/main/java/com/appsmith/server/services/ce/LayoutCollectionServiceCEImpl.java (1)

378-388: Good addition of metrics, but consider refactoring for clarity.

The new code adds valuable metrics for observability. However, consider extracting the calculations into separate methods for improved readability.

Consider refactoring like this:

-String body = actionCollectionDTO.getBody();
-Number lineCount = 0;
-if (body != null && !body.isEmpty()) {
-    lineCount = body.split("\n").length;
-}
-Number actionCount = 0;
-if (actionCollectionDTO.getActions() != null
-        && !actionCollectionDTO.getActions().isEmpty()) {
-    actionCount = actionCollectionDTO.getActions().size();
-}
+Number lineCount = calculateLineCount(actionCollectionDTO.getBody());
+Number actionCount = calculateActionCount(actionCollectionDTO.getActions());

+private Number calculateLineCount(String body) {
+    return (body != null && !body.isEmpty()) ? body.split("\n").length : 0;
+}

+private Number calculateActionCount(List<ActionDTO> actions) {
+    return (actions != null && !actions.isEmpty()) ? actions.size() : 0;
+}
app/server/appsmith-server/src/main/java/com/appsmith/server/layouts/UpdateLayoutServiceCEImpl.java (1)

351-351: Remove Redundant Commented Code

The commented line // observationHelper.createSpan() appears unnecessary and can be removed for cleaner code.

app/server/appsmith-server/src/main/java/com/appsmith/server/onload/internal/OnLoadExecutablesUtilCEImpl.java (1)

56-56: Correct the typo in EXECUTABLE_NAME_TO_EXECUTUTABLE_MAP

There's a typographical error in the constant name EXECUTABLE_NAME_TO_EXECUTUTABLE_MAP. Please correct it to EXECUTABLE_NAME_TO_EXECUTABLE_MAP and update all references accordingly.

Also applies to: 150-150

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 4f55f52 and f8b6b22.

📒 Files selected for processing (8)
  • app/server/appsmith-interfaces/src/main/java/com/appsmith/external/constants/spans/OnLoadSpan.java (1 hunks)
  • app/server/appsmith-interfaces/src/main/java/com/appsmith/external/constants/spans/ce/LayoutSpanCE.java (1 hunks)
  • app/server/appsmith-interfaces/src/main/java/com/appsmith/external/constants/spans/ce/OnLoadSpanCE.java (1 hunks)
  • app/server/appsmith-server/src/main/java/com/appsmith/server/layouts/UpdateLayoutServiceCEImpl.java (11 hunks)
  • app/server/appsmith-server/src/main/java/com/appsmith/server/layouts/UpdateLayoutServiceImpl.java (3 hunks)
  • app/server/appsmith-server/src/main/java/com/appsmith/server/onload/internal/OnLoadExecutablesUtilCEImpl.java (13 hunks)
  • app/server/appsmith-server/src/main/java/com/appsmith/server/services/ce/LayoutActionServiceCEImpl.java (5 hunks)
  • app/server/appsmith-server/src/main/java/com/appsmith/server/services/ce/LayoutCollectionServiceCEImpl.java (2 hunks)
✅ Files skipped from review due to trivial changes (1)
  • app/server/appsmith-interfaces/src/main/java/com/appsmith/external/constants/spans/OnLoadSpan.java
🧰 Additional context used
🔇 Additional comments (11)
app/server/appsmith-server/src/main/java/com/appsmith/server/layouts/UpdateLayoutServiceImpl.java (1)

4-4: LGTM. Observability enhancement looks good.

The addition of ObservationHelperImpl aligns with the PR objectives for improved metrics tracking.

Let's check if similar changes have been made in related classes:

Also applies to: 25-26, 35-36

✅ Verification successful

Observability enhancements are consistent across related classes. Verified successfully.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check for similar observability changes in related classes

# Test: Search for classes with similar naming pattern
rg -l 'class \w+ServiceImpl extends \w+ServiceCEImpl' | xargs rg -l 'ObservationHelperImpl'

# Test: Check for constructor changes in these classes
rg -l 'class \w+ServiceImpl extends \w+ServiceCEImpl' | xargs rg 'public \w+ServiceImpl\(.*ObservationHelperImpl.*\)'

Length of output: 309

app/server/appsmith-interfaces/src/main/java/com/appsmith/external/constants/spans/ce/OnLoadSpanCE.java (5)

1-3: LGTM: Package declaration and import.

The package declaration and import statement are correctly structured and follow Java conventions.


5-5: LGTM: Class declaration.

The class name OnLoadSpanCE is descriptive and follows Java naming conventions. The CE suffix is consistent with Appsmith's naming pattern for Community Edition classes.


7-21: LGTM: Constant definitions structure.

The constant definitions follow Java conventions and consistently use APPSMITH_SPAN_PREFIX. The multi-line formatting for longer values improves readability.


7-21: LGTM: Constant values.

The constant values are consistently prefixed with APPSMITH_SPAN_PREFIX and provide clear context for the operations they represent. The EXECUTABLE_IN_CREATOR_CONTEXT value has been updated as requested in the previous review.


1-22: LGTM: Overall class structure and naming conventions.

The OnLoadSpanCE class is well-structured, follows Java naming conventions, and adheres to the Single Responsibility Principle by focusing solely on defining span constants. The constants are consistently named and organized, making the code easy to read and maintain.

app/server/appsmith-server/src/main/java/com/appsmith/server/services/ce/LayoutCollectionServiceCEImpl.java (2)

406-407: Metrics tagging looks good.

The addition of lineCount and actionCount tags enhances observability, aligning well with the PR objectives.


Line range hint 378-407: Overall, good implementation of metrics for observability.

The changes effectively add metrics for line count and action count, enhancing the observability of the system. This aligns well with the PR objectives. Consider the refactoring suggestion for improved code clarity.

app/server/appsmith-server/src/main/java/com/appsmith/server/layouts/UpdateLayoutServiceCEImpl.java (3)

20-20: Import 'ObservationHelperImpl' Added

The import statement for ObservationHelperImpl is correctly added to support observability.


30-30: Import 'Span' from Micrometer Tracing

The import of Span from io.micrometer.tracing is appropriate for trace span management.


76-76: Added 'observationHelper' Instance

Introducing the observationHelper enhances observability within the service implementation.

@rishabhrathod01 rishabhrathod01 merged commit dc5fbed into release Oct 22, 2024
43 checks passed
@rishabhrathod01 rishabhrathod01 deleted the chore/add-JSObject-update-metrics-ce branch October 22, 2024 08:52
github-actions bot pushed a commit to Zeral-Zhang/appsmith that referenced this pull request Nov 20, 2024
…horg#37001)

## Description


Fixes appsmithorg#36995

## Automation

/ok-to-test tags="@tag.Sanity"

### 🔍 Cypress test results
<!-- This is an auto-generated comment: Cypress test results  -->
> [!TIP]
> 🟢 🟢 🟢 All cypress tests have passed! 🎉 🎉 🎉
> Workflow run:
<https://github.com/appsmithorg/appsmith/actions/runs/11455841055>
> Commit: 7285f3f
> <a
href="https://internal.appsmith.com/app/cypress-dashboard/rundetails-65890b3c81d7400d08fa9ee5?branch=master&workflowId=11455841055&attempt=1"
target="_blank">Cypress dashboard</a>.
> Tags: `@tag.Sanity`
> Spec:
> <hr>Tue, 22 Oct 2024 08:35:48 UTC
<!-- end of auto-generated comment: Cypress test results  -->


## Communication
Should the DevRel and Marketing teams inform users about this change?
- [ ] Yes
- [ ] No


<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

- **New Features**
- Added new constants for layout operations and data extraction to
improve functionality.
- Introduced observability tracking for various methods to enhance
monitoring and performance insights.
- **Bug Fixes**
- Enhanced error handling and logging for action updates and layout
modifications.
- **Refactor**
- Improved clarity and maintainability of methods related to action
collections and layout updates.
- **Chores**
- Updated method signatures to include new observability parameters for
better tracking.
- Added metrics for line and action counts in action collection updates.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Javascript Product Issues related to users writing javascript in appsmith JS Objects Issues related to JS Objects ok-to-test Required label for CI Query & JS Pod Issues related to the query & JS Pod skip-changelog Adding this label to a PR prevents it from being listed in the changelog Task A simple Todo
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Task] Add metric for number of entities co-relation with JS object update call
2 participants