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 newrelic tracking spans to AppViewer engine and AppEditor engine #34716

Open
wants to merge 4 commits into
base: release
Choose a base branch
from

Conversation

dvj1988
Copy link
Contributor

@dvj1988 dvj1988 commented Jul 4, 2024

Description

Add new relic tracking spans to all fn calls in Appviewer and AppEditor engine.

Fixes #Issue Number
or
Fixes Issue URL

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/9806332006
Commit: 39dedf6
Cypress dashboard.
Tags: @tag.Sanity


Fri, 05 Jul 2024 10:05:46 UTC

Communication

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

  • Yes
  • No

Summary by CodeRabbit

  • New Features
    • Enhanced engine setup and data loading with improved telemetry for better performance tracking.
    • Added root span tracing to multiple engine methods for comprehensive performance insights.
  • Improvements
    • Improved performance tracking for app initialization processes by integrating telemetry spans.

Copy link
Contributor

coderabbitai bot commented Jul 4, 2024

Walkthrough

The changes integrate OpenTelemetry to enhance tracing in the app's engine, focusing on performance tracking and telemetry. The updates introduce Span parameters and spans for methods in the AppEngine abstract class and the IAppEngine interface, ensuring detailed tracking of application performance and workflow.

Changes

File Path Change Summary
app/client/src/entities/Engine/index.ts Added imports for Span and telemetry functions. Updated IAppEngine interface and AppEngine abstract class with rootSpan: Span parameters. Integrated span start and end in related methods.
app/client/src/sagas/InitSagas.ts Introduced telemetry span functions within the startAppEngine function for performance and API call tracing.

Sequence Diagram(s)

sequenceDiagram
    participant UI as User Interface
    participant SAGA as InitSagas
    participant AE as AppEngine
    participant TEL as UITelemetry

    UI ->> SAGA: Dispatch startAppEngine
    SAGA ->> TEL: startRootSpan("App Engine Start", {...})
    activate TEL
    TEL -->> SAGA: rootSpan

    SAGA ->> AE: setupEngine(payload, rootSpan)
    activate AE
    AE ->> TEL: startNestedSpan("Engine Setup", rootSpan)
    activate TEL
    TEL -->> AE: span
    
    AE ->> AE: Perform setup
    AE ->> TEL: endSpan(span)
    deactivate TEL
    
    AE ->> AE: loadAppData(payload, rootSpan)
    AE ->> TEL: startNestedSpan("Load App Data", rootSpan)
    activate TEL
    TEL -->> AE: span
    
    AE ->> AE: Perform data load
    AE ->> TEL: endSpan(span)
    deactivate TEL
    
    AE ->> TEL: endSpan(rootSpan)
    deactivate TEL
    AE ->> SAGA: Setup complete
    deactivate AE
Loading

Poem

🐇 In lines of code, neat and clean,
Spans of telemetry keen,
Tracing steps through engine core,
Performance insights we explore.
A leap of change, a span's embrace,
🕰️ Speed and data in their place.
Now our app, with metrics wise,
In the performance circle lies. 🌟


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

@dvj1988 dvj1988 marked this pull request as ready for review July 4, 2024 09:38
@dvj1988 dvj1988 requested a review from ayushpahwa as a code owner July 4, 2024 09:38
@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 4, 2024
@dvj1988
Copy link
Contributor Author

dvj1988 commented Jul 4, 2024

/build-deploy-preview skip-tests=true

Copy link

github-actions bot commented Jul 4, 2024

Deploying Your Preview: https://github.com/appsmithorg/appsmith/actions/runs/9792055839.
Workflow: On demand build Docker image and deploy preview.
skip-tests: true.
env: ``.
PR: 34716.
recreate: .

@dvj1988 dvj1988 added the ok-to-test Required label for CI label Jul 4, 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: 1

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 65eefed and 9d027d9.

Files selected for processing (6)
  • app/client/src/UITelemetry/generateTraces.ts (1 hunks)
  • app/client/src/entities/Engine/AppEditorEngine.ts (8 hunks)
  • app/client/src/entities/Engine/AppViewerEngine.ts (4 hunks)
  • app/client/src/entities/Engine/index.ts (5 hunks)
  • app/client/src/sagas/ActionExecution/PluginActionSaga.ts (3 hunks)
  • app/client/src/sagas/InitSagas.ts (2 hunks)
Additional context used
Biome
app/client/src/entities/Engine/index.ts

[error] 132-132: This default parameter should follow the last required parameter or should be a required parameter.

The last required parameter is here:

A default parameter that precedes a required parameter cannot be omitted at call site.
Unsafe fix: Turn the parameter into a required parameter.

(lint/style/useDefaultParameterLast)

Additional comments not posted (24)
app/client/src/UITelemetry/generateTraces.ts (2)

79-80: LGTM!

The endSpan function correctly handles the optional span parameter using optional chaining.


84-87: LGTM!

The setAttributesToSpan function correctly handles the optional span parameter using optional chaining.

app/client/src/entities/Engine/index.ts (2)

34-41: LGTM!

The changes to the IAppEngine interface align with the PR objective to add New Relic tracking spans to all function calls within the AppViewer and AppEditor engines.


64-66: LGTM!

The changes to the AppEngine abstract class align with the PR objective to add New Relic tracking spans to all function calls within the AppViewer and AppEditor engines.

Also applies to: 69-75

app/client/src/entities/Engine/AppViewerEngine.ts (6)

54-66: LGTM!

The changes to the completeChore method align with the PR objective to add New Relic tracking spans to all function calls within the AppViewer engine.


69-77: LGTM!

The changes to the setupEngine method align with the PR objective to add New Relic tracking spans to all function calls within the AppViewer engine.


Line range hint 96-175:
LGTM!

The changes to the loadAppEntities method align with the PR objective to add New Relic tracking spans to all function calls within the AppViewer engine.


152-158: LGTM!

The addition of the waitForFetchUserSuccess span aligns with the PR objective to add New Relic tracking spans to all function calls within the AppViewer engine.


159-165: LGTM!

The addition of the waitForSegmentInit span aligns with the PR objective to add New Relic tracking spans to all function calls within the AppViewer engine.


166-172: LGTM!

The addition of the waitForFetchEnvironments span aligns with the PR objective to add New Relic tracking spans to all function calls within the AppViewer engine.

app/client/src/entities/Engine/AppEditorEngine.ts (6)

92-102: LGTM!

The changes to the setupEngine method align with the PR objective to add New Relic tracking spans to all function calls within the AppEditor engine.


Line range hint 121-197:
LGTM!

The changes to the loadPageThemesAndActions method align with the PR objective to add New Relic tracking spans to all function calls within the AppEditor engine.


Line range hint 200-241:
LGTM!

The changes to the loadPluginsAndDatasources method align with the PR objective to add New Relic tracking spans to all function calls within the AppEditor engine.


252-261: LGTM!

The changes to the loadAppEntities method align with the PR objective to add New Relic tracking spans to all function calls within the AppEditor engine.


Line range hint 264-327:
LGTM!

The changes to the completeChore method align with the PR objective to add New Relic tracking spans to all function calls within the AppEditor engine.


Line range hint 330-349:
LGTM!

The changes to the loadGit method align with the PR objective to add New Relic tracking spans to all function calls within the AppEditor engine.

app/client/src/sagas/InitSagas.ts (3)

88-92: LGTM!

The new imports for New Relic tracking spans are appropriate.


292-297: LGTM!

The addition of the root span and nested spans in the startAppEngine function is correct and enhances monitoring and performance tracking.

Also applies to: 305-306, 307-310, 315-317, 324-325, 331-331, 339-339, 341-342, 350-351


Line range hint 1290-1291:
LGTM!

The use of startRootSpan and setAttributesToSpan in the executePageLoadActionsSaga function is appropriate and improves performance tracking.

app/client/src/sagas/ActionExecution/PluginActionSaga.ts (5)

Line range hint 105-107:
LGTM!

The new imports for New Relic tracking spans are appropriate.


543-547: LGTM!

The addition of the root span and setting attributes in the executePluginActionTriggerSaga function enhances monitoring and performance tracking.


Line range hint 1061-1061:
LGTM!

The addition of the root span in the runActionSaga function is correct and enhances monitoring and performance tracking.


1290-1290: LGTM!

The addition of the root span and setting attributes in the executePageLoadActionsSaga function enhances monitoring and performance tracking.


1347-1352: LGTM!

The addition of setting attributes to the parent span in the executePluginActionSaga function enhances monitoring and performance tracking.

}

*loadAppURL(pageId: string, pageIdInUrl?: string) {
*loadAppURL(pageId: string, pageIdInUrl: string = "", rootSpan: Span) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Address the default parameter issue.

The default parameter should follow the last required parameter.

-  *loadAppURL(pageId: string, pageIdInUrl: string = "", rootSpan: Span) {
+  *loadAppURL(pageId: string, rootSpan: Span, pageIdInUrl: string = "") {
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
*loadAppURL(pageId: string, pageIdInUrl: string = "", rootSpan: Span) {
*loadAppURL(pageId: string, rootSpan: Span, pageIdInUrl: string = "") {
Tools
Biome

[error] 132-132: This default parameter should follow the last required parameter or should be a required parameter.

The last required parameter is here:

A default parameter that precedes a required parameter cannot be omitted at call site.
Unsafe fix: Turn the parameter into a required parameter.

(lint/style/useDefaultParameterLast)

Copy link

github-actions bot commented Jul 4, 2024

Deploy-Preview-URL: https://ce-34716.dp.appsmith.com

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 UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 9d027d9 and 829d253.

Files selected for processing (2)
  • app/client/src/entities/Engine/index.ts (5 hunks)
  • app/client/src/sagas/InitSagas.ts (2 hunks)
Files skipped from review as they are similar to previous changes (2)
  • app/client/src/entities/Engine/index.ts
  • app/client/src/sagas/InitSagas.ts

Comment on lines 142 to 152
const loadAppUrlSpan = startNestedSpan("AppEngine.loadAppURL", rootSpan);

if (!this._urlRedirect) return;
const newURL: string = yield call(
this._urlRedirect.generateRedirectURL.bind(this),
pageId,
pageIdInUrl,
);

endSpan(loadAppUrlSpan);

Copy link
Contributor

Choose a reason for hiding this comment

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

Is this necessary, no blocking or expensive code here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yeah that's true, I just added them to all components.

Copy link
Contributor

Choose a reason for hiding this comment

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

Also i think the start span should be after the return statement in line 144, so that we don't have an incomplete span.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

loadAppData set the value of _urlRedirect and it is called before loadAppURL in initSagas. This block is present for just type safety.

But yeah I agree, we should avoid any case where there are spans that don't end.

vsvamsi1
vsvamsi1 previously approved these changes Jul 5, 2024
@dvj1988 dvj1988 added ok-to-test Required label for CI and removed ok-to-test Required label for CI labels Jul 5, 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 UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 829d253 and 39dedf6.

Files selected for processing (1)
  • app/client/src/entities/Engine/index.ts (5 hunks)
Files skipped from review as they are similar to previous changes (1)
  • app/client/src/entities/Engine/index.ts

@dvj1988 dvj1988 added ok-to-test Required label for CI and removed ok-to-test Required label for CI labels Jul 5, 2024
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 skip-changelog Adding this label to a PR prevents it from being listed in the changelog
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants