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 JSObject creation flow metrics #37064

Merged
merged 3 commits into from
Oct 28, 2024

Conversation

rishabhrathod01
Copy link
Contributor

@rishabhrathod01 rishabhrathod01 commented Oct 24, 2024

Description

These changes add monitoring spans to analyze the JS action creation flow.

Fixes #37065

Test the changes

Case Screenshot
newRelic metrics for create flow image

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/11500044480
Commit: ebf826f
Cypress dashboard.
Tags: @tag.Sanity
Spec:


Thu, 24 Oct 2024 13:46:02 UTC

Communication

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

  • Yes
  • No

Summary by CodeRabbit

  • New Features

    • Introduced new constants to enhance action validation and repository operations.
    • Added functionality for improved observability in action creation and validation processes.
    • New constants related to data sources and pages for better tracking and logging.
  • Bug Fixes

    • Updated existing constants for better alignment with method names, enhancing clarity and functionality.

Copy link
Contributor

coderabbitai bot commented Oct 24, 2024

Walkthrough

The pull request introduces new constants to the ActionSpanCE, DatasourceSpanCE, and PageSpanCE classes, enhancing their functionality for action and data source tracing. Additionally, the LayoutActionServiceCEImpl class is updated to incorporate these constants, improving the observability and validation processes in action creation and management workflows.

Changes

File Change Summary
app/server/appsmith-interfaces/src/main/java/com/appsmith/external/constants/spans/ce/ActionSpanCE.java Added constants: VALIDATE_AND_GENERATE_ACTION_DOMAIN_BASED_ON_CONTEXT, VALIDATE_AND_SAVE_ACTION_TO_REPOSITORY.
app/server/appsmith-interfaces/src/main/java/com/appsmith/external/constants/spans/ce/DatasourceSpanCE.java Added constants: DATASOURCES, DATASOURCE_SERVICE, FIND_DATASOURCE_BY_ID.
app/server/appsmith-interfaces/src/main/java/com/appsmith/external/constants/spans/ce/PageSpanCE.java Updated constant: GET_PAGE_BY_ID; added constant: IS_NAME_ALLOWED.
app/server/appsmith-server/src/main/java/com/appsmith/server/services/ce/LayoutActionServiceCEImpl.java Updated createAction and validateAndGenerateActionDomainBasedOnContext methods to include new spans.

Assessment against linked issues

Objective Addressed Explanation
Add metrics to sub-process for JS action creation flow (#37065)

Possibly related issues

Possibly related PRs

Suggested labels

Integrations Product, Integrations Pod General

Suggested reviewers

  • nidhi-nair
  • sneha122

🎉 In the code we weave, new constants take flight,
For actions and pages, shining so bright.
With validation in hand, we track every call,
Enhancing our service, we stand proud and tall!
Let's celebrate changes, both big and small! 🌟


📜 Recent review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between abe0d13 and ebf826f.

📒 Files selected for processing (3)
  • app/server/appsmith-interfaces/src/main/java/com/appsmith/external/constants/spans/ce/ActionSpanCE.java (1 hunks)
  • app/server/appsmith-interfaces/src/main/java/com/appsmith/external/constants/spans/ce/DatasourceSpanCE.java (1 hunks)
  • app/server/appsmith-interfaces/src/main/java/com/appsmith/external/constants/spans/ce/PageSpanCE.java (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (3)
  • app/server/appsmith-interfaces/src/main/java/com/appsmith/external/constants/spans/ce/ActionSpanCE.java
  • app/server/appsmith-interfaces/src/main/java/com/appsmith/external/constants/spans/ce/DatasourceSpanCE.java
  • app/server/appsmith-interfaces/src/main/java/com/appsmith/external/constants/spans/ce/PageSpanCE.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.

@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 Evaluation Issues related to JS evaluation on the platform JS Objects Issues related to JS Objects Query & JS Pod Issues related to the query & JS Pod Task A simple Todo labels Oct 24, 2024
@rishabhrathod01 rishabhrathod01 marked this pull request as ready for review October 24, 2024 11:47
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: 0

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

10-10: LGTM! Consider adding a brief comment.

The new span constant follows the established naming pattern and aligns well with the monitoring objectives.

Consider adding a brief Javadoc comment to describe the specific operation this span measures:

+    /** Span for measuring datasource lookup by ID operation */
     public static final String FIND_DATASOURCE_BY_ID = APPSMITH_SPAN_PREFIX + "datasourceService.findById";
app/server/appsmith-server/src/main/java/com/appsmith/server/services/ce/LayoutActionServiceCEImpl.java (1)

378-381: Consider adding explicit error handling for datasource lookup.

While the span is correctly placed, consider adding explicit error handling to better track datasource lookup failures in the metrics.

 return datasourceService
         .findById(savedActionDTO.getDatasource().getId())
         .name(FIND_DATASOURCE_BY_ID)
-        .tap(Micrometer.observation(observationRegistry));
+        .tap(Micrometer.observation(observationRegistry))
+        .onErrorResume(error -> {
+            log.error("Error finding datasource: {}", error.getMessage());
+            return Mono.empty();
+        });
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 0b93768 and abe0d13.

📒 Files selected for processing (4)
  • app/server/appsmith-interfaces/src/main/java/com/appsmith/external/constants/spans/ce/ActionSpanCE.java (1 hunks)
  • app/server/appsmith-interfaces/src/main/java/com/appsmith/external/constants/spans/ce/DatasourceSpanCE.java (1 hunks)
  • app/server/appsmith-interfaces/src/main/java/com/appsmith/external/constants/spans/ce/PageSpanCE.java (1 hunks)
  • app/server/appsmith-server/src/main/java/com/appsmith/server/services/ce/LayoutActionServiceCEImpl.java (5 hunks)
🔇 Additional comments (7)
app/server/appsmith-interfaces/src/main/java/com/appsmith/external/constants/spans/ce/PageSpanCE.java (2)

17-18: LGTM! Clear and consistent span naming.

The updated span name better reflects the actual method being monitored, making it easier to correlate traces with code.


21-22: LGTM! Well-documented span addition.

The new span follows the established naming pattern and is properly documented with its purpose.

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

42-46: LGTM! The new span constants follow conventions and support monitoring objectives.

The added constants properly follow the required "appsmith." prefix convention and clearly describe their respective monitoring points in the JS action creation flow.

Let's verify these constants are being used in the action creation flow:

✅ Verification successful

Let me verify the usage of these span constants in the monitoring context.


The span constants are correctly implemented and used for monitoring

The constants are properly used with Micrometer observations in the action creation flow:

  • VALIDATE_AND_GENERATE_ACTION_DOMAIN_BASED_ON_CONTEXT spans the domain validation in LayoutActionServiceCEImpl
  • VALIDATE_AND_SAVE_ACTION_TO_REPOSITORY spans the repository save operation across service implementations
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for usage of the new span constants in the codebase
rg "validateAndGenerateActionDomainBasedOnContext|validateAndSaveActionToRepository" \
  --type java \
  -g '!**/ActionSpanCE.java'

Length of output: 2416


Script:

#!/bin/bash
# Search for span/tracing usage around these methods
rg -B 2 -A 2 "validateAndGenerateActionDomainBasedOnContext|validateAndSaveActionToRepository" \
  --type java \
  -g '!**/ActionSpanCE.java' \
  -g '!**/test/**'

Length of output: 5592

app/server/appsmith-server/src/main/java/com/appsmith/server/services/ce/LayoutActionServiceCEImpl.java (4)

39-44: LGTM: Span imports are properly organized.

The new span constants are correctly imported and utilized throughout the code.


345-346: LGTM: Proper span placement for action validation.

The observation span correctly wraps the action validation logic.


412-413: LGTM: Proper span placement and error handling for page lookup.

The observation span is correctly placed with appropriate error handling.


425-428: LGTM: Well-structured name validation with proper error handling.

The observation span is correctly placed with appropriate error handling and user-friendly messages.

@rishabhrathod01 rishabhrathod01 added the ok-to-test Required label for CI label Oct 24, 2024
@rishabhrathod01 rishabhrathod01 self-assigned this Oct 24, 2024
@rishabhrathod01 rishabhrathod01 requested review from sneha122 and removed request for nidhi-nair and sondermanish October 24, 2024 11:59
@@ -39,4 +39,9 @@ public class ActionSpanCE {
public static final String DELETE_ACTION = APPSMITH_SPAN_PREFIX + "delete.action";
public static final String FILL_SELF_REFERENCING_PATHS_ACTION =
APPSMITH_SPAN_PREFIX + "action.fillSelfReferencingPaths";

public static final String VALIDATE_AND_GENERATE_ACTION_DOMAIN_BASED_ON_CONTEXT =
Copy link
Contributor

Choose a reason for hiding this comment

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

@rishabhrathod01 can we please follow the nomenclature for spans which uses the namespace of the logical product area that a span is added for? For example, consolidated spans are under appsmith.consolidated-api , git spans are under appsmith.git

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@nidhi-nair There was a concern about span name truncation after 50 chars on newRelic due to which it becomes difficult to filter them. Initially, I followed the practice of appsmith.domain.class.methodName or appsmith.domain.methodName for few span but that exceeds the char limit.

I will update the changes to follow the nomenclature by limiting the domain name char.

Copy link

Failed server tests

  • com.appsmith.server.services.ce.ActionServiceCE_Test#findByIdAndBranchName_forGitConnectedAction_getBranchedAction
  • com.appsmith.server.services.ce.ApplicationServiceCETest#invalidUpdateApplication


// datasource service spans
public static final String DATASOURCE_SERVICE = "datasourceService";
public static final String FIND_DATASOURCE_BY_ID = APPSMITH_SPAN_PREFIX + DATASOURCE_SERVICE + ".findById";
Copy link
Contributor

Choose a reason for hiding this comment

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

@rishabhrathod01 Should we use domain name here instead of datasourceService? I see you have already declared the domain of datasources

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@sneha122 I intended to create datasourceService as a domain name here to ease finding the method.

@sneha122
Copy link
Contributor

@rishabhrathod01 Changes LGTM

@rishabhrathod01 rishabhrathod01 merged commit 5bca179 into release Oct 28, 2024
47 checks passed
@rishabhrathod01 rishabhrathod01 deleted the chore/add-jsaction-create-flow-metrics branch October 28, 2024 09:42
github-actions bot pushed a commit to Zeral-Zhang/appsmith that referenced this pull request Nov 20, 2024
## Description

These changes add monitoring spans to analyze the JS action creation
flow.

Fixes appsmithorg#37065

## Test the changes
| Case | Screenshot  |
|---|---|
| newRelic metrics for create flow |
![image](https://github.com/user-attachments/assets/314cc1d6-9def-49fc-afe9-4c77e84eaf72)
|


## 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/11500044480>
> Commit: ebf826f
> <a
href="https://internal.appsmith.com/app/cypress-dashboard/rundetails-65890b3c81d7400d08fa9ee5?branch=master&workflowId=11500044480&attempt=1"
target="_blank">Cypress dashboard</a>.
> Tags: `@tag.Sanity`
> Spec:
> <hr>Thu, 24 Oct 2024 13:46:02 UTC
<!-- end of auto-generated comment: Cypress test results  -->


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


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

- **New Features**
- Introduced new constants to enhance action validation and repository
operations.
- Added functionality for improved observability in action creation and
validation processes.
- New constants related to data sources and pages for better tracking
and logging.

- **Bug Fixes**
- Updated existing constants for better alignment with method names,
enhancing clarity and functionality.
<!-- 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 Evaluation Issues related to JS evaluation on the platform 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 JS action creation flow metrics
3 participants