Skip to content

chore: Add page load trace with resource, paint and navigation spans#34957

Merged
dvj1988 merged 19 commits intoreleasefrom
chore/new-relic-resource-download-analytics
Jul 30, 2024
Merged

chore: Add page load trace with resource, paint and navigation spans#34957
dvj1988 merged 19 commits intoreleasefrom
chore/new-relic-resource-download-analytics

Conversation

@dvj1988
Copy link

@dvj1988 dvj1988 commented Jul 16, 2024

Description

Implemented a page load performance tracking system using telemetry, capturing key metrics such as Largest Contentful Paint (LCP) and First Contentful Paint (FCP).
Enhanced telemetry data to include browser information and unique session IDs for improved diagnostics.

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


Mon, 29 Jul 2024 13:34:11 UTC

Communication

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

  • Yes
  • No

Summary by CodeRabbit

  • New Features

    • Implemented a page load performance tracking system using telemetry, capturing key metrics such as Largest Contentful Paint (LCP) and First Contentful Paint (FCP).
    • Enhanced telemetry data to include browser information and unique session IDs for improved diagnostics.
  • Improvements

    • Updated telemetry configuration to allow for more granular control over monitored data, optimizing performance and data relevance.
  • Bug Fixes

    • Resolved issues related to the integration of the updated telemetry instrumentation.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jul 16, 2024

Walkthrough

The recent updates significantly enhance the application's telemetry capabilities. A new class, PageLoadInstrumentation, has been introduced to track critical performance metrics such as Largest Contentful Paint (LCP) and First Contentful Paint (FCP). Additionally, the telemetry setup has been optimized to exclude specific resource URLs, and vital browser information alongside a unique session ID has been incorporated. These changes allow for more effective monitoring and diagnostics of the application's performance.

Changes

Files and Summary
app/client/src/UITelemetry/PageLoadInstrumentation.ts
Introduces PageLoadInstrumentation class for tracking page load performance metrics using OpenTelemetry. Implements listeners for key metrics like LCP and FCP, enhancing performance reporting.
app/client/src/UITelemetry/auto-otel-web.ts
Expands telemetry setup by registering PageLoadInstrumentation with the tracerProvider, optimizing data collection by excluding specific resource URLs.
app/client/src/UITelemetry/generateTraces.ts
Enhances telemetry data by including browser information and a unique session ID for better diagnostics.
app/client/src/index.tsx
Updates New Relic agent integration by switching from BrowserAgent to Agent. Adjusts configuration to utilize new monitoring features, improving performance insights.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant PageLoadInstrumentation
    participant OpenTelemetry
    participant NewRelicAgent

    User->>PageLoadInstrumentation: Initiate page load
    PageLoadInstrumentation->>OpenTelemetry: Start root span
    PageLoadInstrumentation->>PageLoadInstrumentation: Observe LCP and FCP
    PageLoadInstrumentation->>NewRelicAgent: Send performance metrics
    NewRelicAgent-->>User: Provide monitoring insights
Loading

🎉🖥️ In the land of code where metrics thrive,
New tools emerge, helping us strive.
LCP and FCP, a dance so bright,
With New Relic’s watch, we gain new sight.
Diagnostics flourish, insights align,
Cheers to progress, our metrics divine! 🌟


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.

@dvj1988
Copy link
Author

dvj1988 commented Jul 25, 2024

/build-deploy-preview skip-tasks=true

@github-actions
Copy link

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

@github-actions
Copy link

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

@dvj1988 dvj1988 marked this pull request as ready for review July 28, 2024 09:59
@dvj1988 dvj1988 changed the title Add auto web instrumentation in otlp sdk chore: Add page load trace with resource, paint and navigation spans Jul 28, 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 28, 2024
@dvj1988 dvj1988 added the ok-to-test Required label for CI label Jul 28, 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 4839110 and 96203a2.

Files selected for processing (4)
  • app/client/src/UITelemetry/PageLoadInstrumentation.ts (1 hunks)
  • app/client/src/UITelemetry/auto-otel-web.ts (2 hunks)
  • app/client/src/UITelemetry/generateTraces.ts (2 hunks)
  • app/client/src/index.tsx (3 hunks)
Additional comments not posted (24)
app/client/src/UITelemetry/generateTraces.ts (3)

10-10: Good job adding the necessary imports!

The inclusion of browserName and browserVersion from react-device-detect is a good step to enhance telemetry data.


20-21: Great addition of a unique session identifier!

The OTLP_SESSION_ID constant generated using nanoid will help in tracking sessions uniquely.


36-38: Excellent enhancement to telemetry attributes!

Including browserName, browserVersion, and otlpSessionId in the telemetry attributes will provide more granular data for diagnostics and analytics.

app/client/src/index.tsx (2)

27-29: Nice work on updating the imports!

The addition of PageViewTiming, PageViewEvent, and Agent from the New Relic package is essential for the new monitoring setup.


57-65: Great enhancement to the New Relic agent configuration!

Including PageViewTiming and PageViewEvent features will significantly improve the application's monitoring capabilities.

app/client/src/UITelemetry/auto-otel-web.ts (3)

23-24: Good addition of necessary imports!

The inclusion of registerInstrumentations and PageLoadInstrumentation is crucial for the new telemetry setup.


31-37: Nice update to the New Relic configuration!

Adding browserAgentEndpoint to the configuration object is a good step to enhance telemetry capabilities.


122-130: Excellent integration of instrumentations!

The registerInstrumentations function call effectively integrates tracerProvider and meterProvider with PageLoadInstrumentation, enhancing telemetry capabilities.

app/client/src/UITelemetry/PageLoadInstrumentation.ts (16)

1-9: Good job with the imports!

The imports are well-organized and relevant to the functionality implemented in this file. This helps in maintaining modularity and readability.


11-19: Class properties are well-defined!

The class properties are clearly defined and initialized. This sets a good foundation for the rest of the class.


21-27: Constructor logic looks solid!

The constructor correctly initializes the class properties and sets up the root span. This ensures that the instrumentation starts with the right configuration.


29-42: Lifecycle methods are well-implemented!

The init, enable, and disable methods correctly manage the setup and teardown of event listeners and observers. This ensures that the instrumentation can be properly controlled.


44-53: Visibility change listener is well-handled!

The visibility change listener correctly updates the page visibility state. This ensures accurate tracking of page visibility metrics.


206-219: Resource timing observer is correctly set up!

The resource timing observer is correctly set up to observe resource entries. This ensures that resource timings are accurately tracked.


55-63: LCP report handling is correct!

The method correctly processes the LCP metric and pushes the timing to the span. This ensures accurate LCP tracking.


65-78: FCP report handling is correct!

The method correctly processes the FCP metric and pushes the timing to the span. This ensures accurate FCP tracking.


105-114: Paint timing handling is efficient!

The method correctly processes paint timing entries and pushes them to the span. This ensures accurate paint timing tracking.


116-134: LCP timing handling is efficient!

The method correctly processes LCP entries and pushes them to the span. This ensures accurate LCP tracking.


136-204: Navigation timing handling is comprehensive!

The method correctly processes navigation timing entries and sets the appropriate attributes on the root span. This ensures comprehensive navigation timing tracking.


229-284: Resource timing handling is efficient!

The method correctly processes resource timing entries and pushes them to the span. This ensures accurate resource timing tracking.


80-99: Element name extraction is well-implemented!

The method correctly extracts the name of an element up to a certain depth. This ensures accurate element identification.


101-103: String conversion utility is efficient!

The method correctly converts kebab-case strings to screaming snake case. This ensures consistent string formatting.


286-288: Resource entry key generation is correct!

The method correctly generates a unique key for resource entries. This ensures accurate identification of resource entries.


290-313: Resource timing polling is correctly implemented!

The method correctly polls resource timing entries and processes them. This ensures accurate tracking of resource timings even if the observer is not available.

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 96203a2 and 5178717.

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

@dvj1988 dvj1988 requested review from rajatagrawal and vsvamsi1 July 28, 2024 10:36
@rajatagrawal
Copy link
Contributor

@dvj1988 Is the pageLoad telemetry disabled for self hosted instances and can be conditionally switched on for it ?

@dvj1988
Copy link
Author

dvj1988 commented Jul 29, 2024

@dvj1988 Is the pageLoad telemetry disabled for self hosted instances and can be conditionally switched on for it ?

@rajatagrawal Yes, This is implemented as a plugin to our OTLP implementation. So when we switch on OTLP the page load metrics also will get enabled.

@dvj1988 dvj1988 added ok-to-test Required label for CI and removed ok-to-test Required label for CI labels Jul 29, 2024
@dvj1988 dvj1988 requested a review from rahulbarwal July 29, 2024 13:06
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 5178717 and b8ee33f.

Files selected for processing (2)
  • app/client/src/UITelemetry/auto-otel-web.ts (2 hunks)
  • app/client/src/UITelemetry/generateTraces.ts (2 hunks)
Files skipped from review as they are similar to previous changes (2)
  • app/client/src/UITelemetry/auto-otel-web.ts
  • app/client/src/UITelemetry/generateTraces.ts

@dvj1988 dvj1988 merged commit e4fc6d2 into release Jul 30, 2024
@dvj1988 dvj1988 deleted the chore/new-relic-resource-download-analytics branch July 30, 2024 03:17
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