Skip to content

chore: added instrumentation for js object update#36999

Merged
NilanshBansal merged 2 commits intoreleasefrom
chore/issue-36996/adding-instrumentation-js-action-update
Oct 22, 2024
Merged

chore: added instrumentation for js object update#36999
NilanshBansal merged 2 commits intoreleasefrom
chore/issue-36996/adding-instrumentation-js-action-update

Conversation

@NilanshBansal
Copy link
Contributor

@NilanshBansal NilanshBansal commented Oct 21, 2024

Description

This PR adds the granular level instrumentation for the JS Object update calls.

Fixes #36996

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/11444602012
Commit: 2e31a47
Cypress dashboard.
Tags: @tag.Sanity
Spec:


Mon, 21 Oct 2024 17:07:30 UTC

Communication

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

  • Yes
  • No

Summary by CodeRabbit

  • New Features

    • Introduced new constants for action spans, application spans, layout spans, and page spans to enhance tracking capabilities.
    • Enhanced observability features in services related to page load and executable management.
  • Bug Fixes

    • Improved error handling for page and layout ID retrieval.
  • Refactor

    • Updated constructors and method signatures to incorporate new observability dependencies.

These changes aim to improve tracking, error handling, and overall performance of the application.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Oct 21, 2024

Walkthrough

The changes in this pull request involve the addition of multiple new constants across various classes in the com.appsmith.external.constants.spans.ce package, enhancing the observability and tracking capabilities of the application. Additionally, modifications to the ExecutableOnPageLoadServiceCEImpl, ExecutableOnPageLoadServiceImpl, OnLoadExecutablesUtilCEImpl, and OnLoadExecutablesUtilImpl classes introduce new dependencies related to observability, improving the error handling and logging of method calls.

Changes

File Change Summary
.../ActionSpanCE.java Added constant FILL_SELF_REFERENCING_PATHS_ACTION.
.../ApplicationSpanCE.java Added constant APPLICATION_SAVE_LAST_EDIT_INFO_SPAN.
.../LayoutSpanCE.java Added constants: EXTRACT_AND_SET_EXECUTABLE_BINDINGS_IN_GRAPH_EDGES, RECURSIVELY_ADD_EXECUTABLES_AND_THEIR_DEPENDENTS_TO_GRAPH_FROM_BINDINGS, ADD_WIDGET_RELATIONSHIP_TO_GRAPH, COMPUTE_ON_PAGE_LOAD_EXECUTABLES_SCHEDULING_ORDER, FILTER_AND_TRANSFORM_SCHEDULING_ORDER_TO_DTO.
.../PageSpanCE.java Added constant GET_PAGE_BY_ID_AND_LAYOUTS_ID.
.../ExecutableOnPageLoadServiceCEImpl.java Added field private final ObservationRegistry observationRegistry; enhanced observability in methods.
.../ExecutableOnPageLoadServiceImpl.java Updated constructor to include ObservationRegistry observationRegistry.
.../OnLoadExecutablesUtilCEImpl.java Added fields private final ObservationRegistry observationRegistry and private final ObservationHelperImpl observationHelper; enhanced observability in methods.
.../OnLoadExecutablesUtilImpl.java Updated constructor to include ObservationRegistry observationRegistry and ObservationHelperImpl observationHelper.

Assessment against linked issues

Objective Addressed Explanation
Add instrumentation for fillSelfReferencingPaths and other methods (#36996)
Add observability features for various methods (#36996)

Possibly related PRs

Suggested labels

Stability Pod, Stability Issue

Suggested reviewers

  • nidhi-nair
  • dvj1988
  • sondermanish

🎉 In code we trust, with constants anew,
Observability shines bright, guiding us through.
From actions to layouts, we track every path,
With error handling strong, we’ll avoid the wrath!
So here's to the changes, let’s raise a cheer,
For clearer insights, our goals are quite near! 🎊


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.

@NilanshBansal NilanshBansal requested review from rishabhrathod01 and sneha122 and removed request for nidhi-nair and sondermanish October 21, 2024 14:25
@NilanshBansal NilanshBansal self-assigned this Oct 21, 2024
@github-actions github-actions bot added Integrations Pod General Issues related to the Integrations Pod that don't fit into other tags. Integrations Pod Integrations Product Issues related to a specific integration Query & JS Pod Issues related to the query & JS Pod Task A simple Todo skip-changelog Adding this label to a PR prevents it from being listed in the changelog labels Oct 21, 2024
@NilanshBansal NilanshBansal added the ok-to-test Required label for CI label Oct 21, 2024
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: 3

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

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

The new constant APPLICATION_SAVE_LAST_EDIT_INFO_SPAN is well-named and consistent with the existing pattern. It's correctly using the APPLICATION_ID_SPAN as a base.

Consider adding a brief comment above the constant to describe its purpose, similar to:

// Span for tracking the saving of last edit information
public static final String APPLICATION_SAVE_LAST_EDIT_INFO_SPAN = APPLICATION_ID_SPAN + ".save_last_edit_info";
app/server/appsmith-interfaces/src/main/java/com/appsmith/external/constants/spans/ce/PageSpanCE.java (1)

18-18: Approved with a minor suggestion.

The new constant GET_PAGE_BY_ID_AND_LAYOUTS_ID is well-defined and aligns with the PR objectives. For consistency with other constants, consider using uppercase for the entire string value.

-    public static final String GET_PAGE_BY_ID_AND_LAYOUTS_ID = APPSMITH_SPAN_PREFIX + "getPageByIdAndLayoutsId";
+    public static final String GET_PAGE_BY_ID_AND_LAYOUTS_ID = APPSMITH_SPAN_PREFIX + "GET_PAGE_BY_ID_AND_LAYOUTS_ID";
app/server/appsmith-interfaces/src/main/java/com/appsmith/external/constants/spans/ce/ActionSpanCE.java (1)

40-41: LGTM. Consider grouping related constants.

The new constant follows the established naming convention and uses the correct prefix. It's well-aligned with the PR objectives.

Consider grouping this constant with other action-related spans for better organization.

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 1f72d75 and fb15afc.

📒 Files selected for processing (8)
  • 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/ApplicationSpanCE.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/PageSpanCE.java (1 hunks)
  • app/server/appsmith-server/src/main/java/com/appsmith/server/newpages/onload/ExecutableOnPageLoadServiceCEImpl.java (5 hunks)
  • app/server/appsmith-server/src/main/java/com/appsmith/server/newpages/onload/ExecutableOnPageLoadServiceImpl.java (2 hunks)
  • app/server/appsmith-server/src/main/java/com/appsmith/server/onload/internal/OnLoadExecutablesUtilCEImpl.java (10 hunks)
  • app/server/appsmith-server/src/main/java/com/appsmith/server/onload/internal/OnLoadExecutablesUtilImpl.java (2 hunks)
🧰 Additional context used
🔇 Additional comments (15)
app/server/appsmith-server/src/main/java/com/appsmith/server/onload/internal/OnLoadExecutablesUtilImpl.java (1)

4-4: LGTM. Instrumentation added as per requirements.

The changes align with the PR objectives. New dependencies and constructor modifications enhance observability.

Let's ensure consistency across the codebase:

Also applies to: 8-8, 19-22

app/server/appsmith-server/src/main/java/com/appsmith/server/newpages/onload/ExecutableOnPageLoadServiceImpl.java (4)

10-10: LGTM: Import statement for ObservationRegistry.

The import is correctly added and aligns with the new parameter in the constructor.


23-24: LGTM: Constructor signature updated with ObservationRegistry.

The new parameter is correctly added and aligns with the PR objective of adding instrumentation.


25-31: LGTM: Superclass constructor call updated.

The superclass constructor call correctly includes the new observationRegistry parameter, ensuring proper initialization.


Line range hint 1-33: Verify consistency across related classes.

The changes in this file look good and align with the PR objective. To ensure overall consistency, it would be beneficial to verify if similar changes have been made in related classes that might also require observability features.

✅ Verification successful

Consistency Verified Across Related Classes

The addition of ObservationRegistry in ExecutableOnPageLoadServiceImpl.java aligns with the implemented changes in related classes, ensuring consistency in observability features across the codebase.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

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

# Test: Search for classes with similar naming patterns
echo "Related classes:"
fd -e java '(ExecutableOnPageLoad|OnLoadExecutables).*Impl\.java$'

# Test: Check for ObservationRegistry usage in these classes
echo "\nObservationRegistry usage in related classes:"
fd -e java '(ExecutableOnPageLoad|OnLoadExecutables).*Impl\.java$' -x rg -n 'ObservationRegistry'

Length of output: 1227

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

21-22: LGTM

The constant is well-named and follows the class conventions.


23-23: LGTM

The constant is appropriately named and follows the class conventions.


24-25: LGTM

The constant is well-defined and follows the class naming conventions.


26-27: LGTM

The constant is appropriately named and adheres to the class conventions.


19-27: Overall, the changes look good with one minor issue

The new constants added for instrumentation align well with the PR objectives. They follow the existing naming conventions and provide clear, descriptive names for the spans. Just make sure to fix the typo in the first constant as mentioned earlier.

app/server/appsmith-server/src/main/java/com/appsmith/server/newpages/onload/ExecutableOnPageLoadServiceCEImpl.java (5)

17-31: Imports added for observability enhancements

The new imports and constants are correctly added to support the observability features in the code.


43-43: ObservationRegistry field declaration is appropriate

The ObservationRegistry is properly declared as a final field, ensuring it's correctly injected and used for tracing.


58-59: Instrumentation added to fillSelfReferencingPaths method

The observability enhancements using .name(FILL_SELF_REFERENCING_PATHS_ACTION) and .tap(Micrometer.observation(observationRegistry)) are correctly applied to the reactive chain.


81-82: Observability incorporated in findByIdAndLayoutsId call

The addition of .name(GET_PAGE_BY_ID_AND_LAYOUTS_ID) and .tap(Micrometer.observation(observationRegistry)) appropriately enhances the tracing of this method.


107-108: Enhanced tracing in saveLastEditInformation operation

Including .name(APPLICATION_SAVE_LAST_EDIT_INFO_SPAN) and .tap(Micrometer.observation(observationRegistry)) effectively adds observability to this operation.

Copy link
Contributor

@rishabhrathod01 rishabhrathod01 left a comment

Choose a reason for hiding this comment

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

LGTM

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: 2

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between fb15afc and 2e31a47.

📒 Files selected for processing (2)
  • app/server/appsmith-interfaces/src/main/java/com/appsmith/external/constants/spans/ce/LayoutSpanCE.java (1 hunks)
  • app/server/appsmith-server/src/main/java/com/appsmith/server/onload/internal/OnLoadExecutablesUtilCEImpl.java (10 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • app/server/appsmith-interfaces/src/main/java/com/appsmith/external/constants/spans/ce/LayoutSpanCE.java
🧰 Additional context used

Comment on lines +188 to +189
.name(RECURSIVELY_ADD_EXECUTABLES_AND_THEIR_DEPENDENTS_TO_GRAPH_FROM_BINDINGS)
.tap(Micrometer.observation(observationRegistry))
Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Refactor repetitive Micrometer instrumentation code

The code pattern with .name(...) and .tap(Micrometer.observation(observationRegistry)) is used multiple times. Consider creating a utility method to encapsulate this pattern and reduce duplication.

Example:

private <T> Mono<T> instrument(Mono<T> mono, String name) {
    return mono
        .name(name)
        .tap(Micrometer.observation(observationRegistry));
}

Then, replace:

someMonoOperation()
    .name(SOME_CONSTANT)
    .tap(Micrometer.observation(observationRegistry));

with:

instrument(someMonoOperation(), SOME_CONSTANT);

Also applies to: 649-650, 930-931, 948-949, 1002-1003

// TODO : Add all the global variables exposed on the client side.
private final Set<String> APPSMITH_GLOBAL_VARIABLES = Set.of();
private final ObservationRegistry observationRegistry;
private final ObservationHelperImpl observationHelper;
Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Use interface type for observationHelper

Consider declaring observationHelper as ObservationHelper instead of ObservationHelperImpl to depend on the interface rather than the implementation.

Apply this diff:

-private final ObservationHelperImpl observationHelper;
+private final ObservationHelper observationHelper;
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
private final ObservationHelperImpl observationHelper;
private final ObservationHelper observationHelper;

@NilanshBansal NilanshBansal merged commit 4f55f52 into release Oct 22, 2024
@NilanshBansal NilanshBansal deleted the chore/issue-36996/adding-instrumentation-js-action-update branch October 22, 2024 05:58
github-actions bot pushed a commit to Zeral-Zhang/appsmith that referenced this pull request Nov 20, 2024
## Description
> This PR adds the granular level instrumentation for the JS Object
update calls.

Fixes appsmithorg#36996

## 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/11444602012>
> Commit: 2e31a47
> <a
href="https://internal.appsmith.com/app/cypress-dashboard/rundetails-65890b3c81d7400d08fa9ee5?branch=master&workflowId=11444602012&attempt=1"
target="_blank">Cypress dashboard</a>.
> Tags: `@tag.Sanity`
> Spec:
> <hr>Mon, 21 Oct 2024 17:07:30 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**
- Introduced new constants for action spans, application spans, layout
spans, and page spans to enhance tracking capabilities.
- Enhanced observability features in services related to page load and
executable management.

- **Bug Fixes**
	- Improved error handling for page and layout ID retrieval.

- **Refactor**
- Updated constructors and method signatures to incorporate new
observability dependencies.

These changes aim to improve tracking, error handling, and overall
performance of the application.
<!-- 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

Integrations Pod General Issues related to the Integrations Pod that don't fit into other tags. Integrations Pod Integrations Product Issues related to a specific integration 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 instrumentation for the following methods

2 participants