Skip to content

chore: Add newrelic tracking spans to AppViewer engine and AppEditor engine#34716

Merged
dvj1988 merged 5 commits intoreleasefrom
chore/add-app-engine-traces
Jul 11, 2024
Merged

chore: Add newrelic tracking spans to AppViewer engine and AppEditor engine#34716
dvj1988 merged 5 commits intoreleasefrom
chore/add-app-engine-traces

Conversation

@dvj1988
Copy link

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


Wed, 10 Jul 2024 05:32:52 UTC

Communication

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

  • Yes
  • No

Summary by CodeRabbit

  • New Features

    • Enhanced app performance tracking with added telemetry spans for key functions.
  • Tests

    • Updated test cases to include telemetry span tracking, ensuring better performance monitoring and validation.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jul 4, 2024

Walkthrough

This update introduces telemetry spans for performance tracking within the Engine module and InitSagas. It modifies method signatures across interfaces and classes to include root span parameters and integrates span functionalities in the initSagas tests. These changes enhance the monitoring capability of the application, enabling detailed performance tracing.

Changes

File Change Summary
.../Engine/index.ts Added telemetry span parameters to methods in IAppEngine and AppEngine abstract class for tracing execution.
.../sagas/InitSagas.ts Introduced telemetry functions for generating spans for performance tracking within the startAppEngine function.
.../sagas/__tests__/initSagas.test.ts Incorporated startRootSpan to create a mockRootSpan for span-related calls in tests.

Sequence Diagram(s)

sequenceDiagram
    participant UI
    participant startAppEngine
    participant Engine
    participant Telemetry

    UI ->> startAppEngine: Dispatch action
    startAppEngine ->> Telemetry: startRootSpan("startAppEngine")
    Telemetry -->> startAppEngine: rootSpan
    startAppEngine ->> Engine: setupEngine(payload, rootSpan)
    Engine ->> Telemetry: startNestedSpan("setupEngine", rootSpan)
    Engine ->> Engine: Perform setup tasks
    Engine ->> Telemetry: endSpan(setupEngineSpan)
    Engine ->> startAppEngine: Setup complete
    startAppEngine ->> Engine: loadAppData(payload, rootSpan)
    Engine ->> Telemetry: startNestedSpan("loadAppData", rootSpan)
    Engine ->> Engine: Load application data
    Engine ->> Telemetry: endSpan(loadAppDataSpan)
    Engine -->> startAppEngine: Data loading complete
    startAppEngine ->> Telemetry: endSpan(rootSpan)
    startAppEngine -->> UI: Application ready
Loading

Poem

In the code where data flows,
New spans trace where the journey goes.
Telemetry paves paths so bright,
Tracking code in morning light.
With each change, performance bestows,
Efficiency where the engine glows.
Hoppy changes taking flight! 🐇✨


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
Author

dvj1988 commented Jul 4, 2024

/build-deploy-preview skip-tests=true

@github-actions
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
@dvj1988 dvj1988 requested review from rajatagrawal and vsvamsi1 July 4, 2024 09:40
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)

@github-actions
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
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
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
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
@dvj1988 dvj1988 added ok-to-test Required label for CI and removed ok-to-test Required label for CI labels Jul 10, 2024
@dvj1988 dvj1988 requested a review from vsvamsi1 July 10, 2024 05:04
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 39dedf6 and 9267930.

Files selected for processing (1)
  • app/client/src/sagas/tests/initSagas.test.ts (2 hunks)
Additional comments not posted (6)
app/client/src/sagas/__tests__/initSagas.test.ts (6)

13-13: Import statement looks good.

The import statement for startRootSpan is necessary for the changes.


54-55: Creating mockRootSpan looks good.

Creating mockRootSpan using startRootSpan is necessary for the test cases.


60-60: Updated method call looks good.

The setupEngine method is correctly called with action.payload and mockRootSpan.


66-66: Updated method call looks good.

The loadAppData method is correctly called with action.payload, mockResponse.data, and mockRootSpan.


71-75: Updated method call looks good.

The loadAppURL method is correctly called with an object containing pageId, pageIdInUrl, and rootSpan.


82-82: Updated method calls look good.

The methods loadAppEntities, loadGit, and completeChore are correctly called with mockRootSpan.

Also applies to: 85-85, 87-87

@dvj1988 dvj1988 merged commit 6f856b5 into release Jul 11, 2024
@dvj1988 dvj1988 deleted the chore/add-app-engine-traces branch July 11, 2024 10:07
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.

2 participants