Skip to content

feat: add transaction performance metrics#26332

Merged
matthewwalsh0 merged 66 commits intodevelopfrom
feat/transaction-traces
Aug 22, 2024
Merged

feat: add transaction performance metrics#26332
matthewwalsh0 merged 66 commits intodevelopfrom
feat/transaction-traces

Conversation

@matthewwalsh0
Copy link
Copy Markdown
Member

@matthewwalsh0 matthewwalsh0 commented Aug 2, 2024

Description

Add initial custom instrumentation around transactions initiated from a dApp.

Specifically:

  • Refactor trace utility function to support no callback argument and only start a trace to be manually ended later.
  • Add endTrace utility function.
  • Add endBackgroundTrace action to contribute to background metrics from the UI.
  • Always trace if in developer build or METAMASK_DEBUG is set.
  • Pass trace callback and traceContext to TransactionController.
  • End Notification Display trace (started from controller) as soon as transaction confirmation is rendered with matching ID.

Open in GitHub Codespaces

Related issues

Fixes: #2850

Manual testing steps

Screenshots/Recordings

Before

After

Pre-merge author checklist

Pre-merge reviewer checklist

  • I've manually tested the PR (e.g. pull and build branch, run the app, test code being changed).
  • I confirm that this PR addresses all acceptance criteria described in the ticket it closes and includes the necessary testing evidence such as recordings and or screenshots.

matthewwalsh0 and others added 30 commits July 22, 2024 13:06
Simplify Sentry logic.
Improve Sentry logging.
Fix toggle timings.
Add Sentry buttons in developer options.
Include type in log message.
Add local timings.
Move internal messages to separte logger.
Pass span to callback.
Remove package script duplication.
Fix unit tests.
@matthewwalsh0 matthewwalsh0 requested a review from a team as a code owner August 19, 2024 12:57
@matthewwalsh0 matthewwalsh0 requested review from a team as code owners August 19, 2024 23:50
@metamaskbot
Copy link
Copy Markdown
Collaborator

Builds ready [563731f]
Page Load Metrics (94 ± 26 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint703931276933
domContentLoaded44290905426
load52301945426
domInteractive10107382512
Bundle size diffs [🚨 Warning! Bundle size has increased!]
  • background: 1.5 KiB (0.04%)
  • ui: -1.3 KiB (-0.02%)
  • common: 1.42 KiB (0.02%)

jpuri
jpuri previously approved these changes Aug 20, 2024
Copy link
Copy Markdown
Contributor

@jpuri jpuri left a comment

Choose a reason for hiding this comment

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

Changes look good 👍

@matthewwalsh0 matthewwalsh0 dismissed stale reviews from pedronfigueiredo and jpuri via bfbdb98 August 21, 2024 14:07
Comment on lines +16 to +22
req.traceContext = await trace({
name: 'Transaction',
id,
tags: { source: 'dapp' },
});

await trace({ name: 'Middleware', id, parentContext: req.traceContext });
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

should this be in a try/catch?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I don't believe there is any known error scenarios here, so it shouldn't introduce any more risk than any other middleware for example.

@socket-security
Copy link
Copy Markdown

socket-security bot commented Aug 21, 2024

New and removed dependencies detected. Learn more about Socket for GitHub ↗︎

Package New capabilities Transitives Size Publisher
npm/@metamask/nonce-tracker@6.0.0 None 0 29.1 kB lgbot
npm/@metamask/transaction-controller@35.2.0 network 0 1.85 MB metamaskbot

🚮 Removed packages: npm/@metamask/transaction-controller@34.0.0

View full report↗︎

@sonarqubecloud
Copy link
Copy Markdown

@metamaskbot
Copy link
Copy Markdown
Collaborator

Builds ready [aff65ce]
Page Load Metrics (166 ± 186 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint801751082613
domContentLoaded49117742010
load551851166387186
domInteractive185230105
Bundle size diffs [🚨 Warning! Bundle size has increased!]
  • background: 13.75 KiB (0.39%)
  • ui: -1.3 KiB (-0.02%)
  • common: 3.49 KiB (0.04%)

@matthewwalsh0 matthewwalsh0 merged commit 862c9c3 into develop Aug 22, 2024
@matthewwalsh0 matthewwalsh0 deleted the feat/transaction-traces branch August 22, 2024 08:48
@github-actions github-actions bot locked and limited conversation to collaborators Aug 22, 2024
@metamaskbot metamaskbot added the release-12.5.0 Issue or pull request that will be included in release 12.5.0 label Aug 22, 2024
@gauthierpetetin gauthierpetetin added release-12.4.0 Issue or pull request that will be included in release 12.4.0 and removed release-12.5.0 Issue or pull request that will be included in release 12.5.0 labels Sep 11, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

release-12.4.0 Issue or pull request that will be included in release 12.4.0 team-confirmations Push issues to confirmations team team-tiger-deprecated DEPRECATED: team no longer exists

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants