Skip to content

chore: adding addition telemetry to cover JSONForm widget's performance#35229

Merged
rajatagrawal merged 2 commits intoreleasefrom
test15
Jul 29, 2024
Merged

chore: adding addition telemetry to cover JSONForm widget's performance#35229
rajatagrawal merged 2 commits intoreleasefrom
test15

Conversation

@vsvamsi1
Copy link
Contributor

@vsvamsi1 vsvamsi1 commented Jul 26, 2024

Description

We need to profile a few functions in JSON forms, observed that in some customer's apps the following functions

  • clearErrors
  • parseAndSaveFieldState
    takes as much 10% in main thread scripting. We are adding setError just to check if this function is performant or not as well.

Fixes #35228

Warning

If no issue exists, please create an issue first, and check with the maintainers if the issue is valid.

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/10114403810
Commit: 90f5c31
Cypress dashboard.
Tags: @tag.Sanity
Spec:


Fri, 26 Jul 2024 16:46:46 UTC

Communication

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

  • Yes
  • No

Summary by CodeRabbit

  • New Features

    • Introduced telemetry tracking around function executions to improve observability and performance monitoring.
    • Enhanced error-clearing logic in the form widget to include telemetry tracing for better analysis.
  • Improvements

    • Added performance tracking to the parseAndSaveFieldState method in the JSONFormWidget for optimized performance insights.

@vsvamsi1 vsvamsi1 requested review from dvj1988 and rajatagrawal July 26, 2024 16:14
@vsvamsi1 vsvamsi1 self-assigned this Jul 26, 2024
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jul 26, 2024

Walkthrough

This update significantly enhances telemetry in the JSONFormWidgets by introducing a utility function, startAndEndSpanForFn, which manages tracing spans effectively. This function is integrated into the useRegisterFieldValidity hook and the parseAndSaveFieldState method, thereby improving observability and performance monitoring without disrupting existing logic. The modifications aim to deliver better insights into critical operations within the application, ensuring that developers can track performance more effectively.

Changes

Files Change Summary
app/client/src/UITelemetry/generateTraces.ts Introduced startAndEndSpanForFn for managing spans in tracing, enhancing telemetry capabilities for function execution.
app/client/src/widgets/JSONFormWidget/fields/useRegisterFieldValidity.ts Wrapped clearErrors function in startAndEndSpanForFn for telemetry, improving monitoring of error-clearing operations.
app/client/src/widgets/JSONFormWidget/widget/index.tsx Added telemetry tracking to parseAndSaveFieldState using startRootSpan and endSpan, enabling performance insights for this method.

Sequence Diagram(s)

sequenceDiagram
    participant C as Client
    participant W as JSONFormWidget
    participant T as Telemetry
    
    C->>W: Trigger clearErrors
    W->>T: startAndEndSpanForFn(clearErrors)
    T-->>W: Begin telemetry span
    W->>W: clearErrors(fieldName)
    T-->>W: End telemetry span
    W-->>C: Complete clearErrors operation
Loading
sequenceDiagram
    participant C as Client
    participant W as JSONFormWidget
    participant T as Telemetry
    
    C->>W: Trigger parseAndSaveFieldState
    W->>T: startRootSpan(parseAndSaveFieldState)
    T-->>W: Begin telemetry span
    W->>W: parseAndSaveFieldState()
    T-->>W: End telemetry span
    W-->>C: Complete parseAndSaveFieldState operation
Loading

Assessment against linked issues

Objective Addressed Explanation
Add telemetry for clearErrors (##35228)
Add telemetry for parseAndSaveFieldState (##35228)

🎉 In the code, we’ve spun,
With spans that track and run.
Telemetry now shines bright,
Monitoring errors with delight!
JSON forms, now fast and clear,
Performance insights are finally here! 🌟


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>.
    • 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 generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @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 as 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.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

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.

@vsvamsi1 vsvamsi1 changed the title adding addition telemetry to cover JSONForm widget's performance chore adding addition telemetry to cover JSONForm widget's performance Jul 26, 2024
@github-actions github-actions bot added Performance Issues related to performance Performance infra all issue related to the performance infra Task A simple Todo labels Jul 26, 2024
@vsvamsi1 vsvamsi1 changed the title chore adding addition telemetry to cover JSONForm widget's performance chore: adding addition telemetry to cover JSONForm widget's performance Jul 26, 2024
@vsvamsi1 vsvamsi1 added the ok-to-test Required label for CI label Jul 26, 2024
@github-actions github-actions bot added the skip-changelog Adding this label to a PR prevents it from being listed in the changelog label Jul 26, 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: 0

Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 4bf6671 and 3a79b32.

Files selected for processing (3)
  • app/client/src/UITelemetry/generateTraces.ts (1 hunks)
  • app/client/src/widgets/JSONFormWidget/fields/useRegisterFieldValidity.ts (2 hunks)
  • app/client/src/widgets/JSONFormWidget/widget/index.tsx (3 hunks)
Additional comments not posted (5)
app/client/src/widgets/JSONFormWidget/fields/useRegisterFieldValidity.ts (2)

10-10: Good job on importing the telemetry function.

The import statement for startAndEndSpanForFn is necessary for the new telemetry functionality.


38-40: Well done on adding telemetry tracing.

The use of startAndEndSpanForFn to wrap the clearErrors function call enhances observability without altering the core logic.

However, ensure that all function calls to useRegisterFieldValidity are correctly handling the new telemetry tracing.

app/client/src/UITelemetry/generateTraces.ts (1)

90-99: Excellent implementation of the telemetry function.

The function startAndEndSpanForFn is correctly implemented to start a span, execute a function, and end the span. This ensures proper resource management and enhances telemetry capabilities.

app/client/src/widgets/JSONFormWidget/widget/index.tsx (2)

71-71: Good job on importing the telemetry functions.

The import statements for startRootSpan and endSpan are necessary for the new telemetry functionality.


Line range hint 655-669: Well done on adding telemetry tracing.

The use of startRootSpan and endSpan to wrap the parseAndSaveFieldState method enhances observability and performance monitoring.

However, ensure that all method calls to parseAndSaveFieldState are correctly handling the new telemetry tracing.

@github-actions github-actions bot added skip-changelog Adding this label to a PR prevents it from being listed in the changelog and removed skip-changelog Adding this label to a PR prevents it from being listed in the changelog labels Jul 26, 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: 0

Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 3a79b32 and 90f5c31.

Files selected for processing (1)
  • app/client/src/widgets/JSONFormWidget/fields/useRegisterFieldValidity.ts (2 hunks)
Files skipped from review as they are similar to previous changes (1)
  • app/client/src/widgets/JSONFormWidget/fields/useRegisterFieldValidity.ts

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ok-to-test Required label for CI Performance infra all issue related to the performance infra Performance Issues related to performance 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.

Add more telemetry for JSONFormWidgets

2 participants