fix: nest AssetsController Sentry sub spans under cold-start parents - #9672
Merged
Conversation
Contributor
Author
|
@metamaskbot publish-preview |
Contributor
|
Preview builds have been published. Learn how to use preview builds in other projects. Expand for full list of packages and versions. |
salimtb
commented
Jul 28, 2026
| 2, | ||
| expect.objectContaining({ | ||
| name: 'AggregatedBalanceSelector', | ||
| parentContext: parentSpan, |
Contributor
Author
There was a problem hiding this comment.
this indicate it's a sub span
Avoid Sentry rate limits by nesting pipeline timings as subspans and emitting them only on the first unlock-session fetch, plus a single AggregatedBalanceSelector span for all wallets.
salimtb
force-pushed
the
fix/assets-controller-sentry-subspans
branch
from
July 28, 2026 15:09
02071e9 to
9a24045
Compare
Comment on lines
+1819
to
+1825
| await this.#executeMiddlewares( | ||
| fastSources, | ||
| request, | ||
| {}, | ||
| parentContext, | ||
| shouldTrace, | ||
| ); |
Contributor
There was a problem hiding this comment.
Huge code smell. Make this an object parameter.
Contributor
There was a problem hiding this comment.
Actually, did some reading and put 2 and 2 together.
Core has upgraded to TS 5.x, meaning decorators are an option 👀. This tracing is a really good potential use-case for a clean decorator approach.
Prithpal-Sooriya
approved these changes
Jul 29, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Avoid Sentry rate limits by nesting pipeline timings as subspans and emitting them only on the first unlock-session fetch, plus a single AggregatedBalanceSelector span for all wallets.
Explanation
References
Checklist
Note
Low Risk
Changes are limited to observability wiring and defensive error handling; asset fetch and state-update behavior is unchanged aside from when spans are emitted.
Overview
Reduces Sentry span volume and improves Assets Health dashboard fidelity by restructuring how
AssetsControlleremits traces.Tracing helpers — Inline
#emitTraceis replaced byutils/trace.ts(emitTrace/withTrace). Omittingtraceno-ops at call sites; numeric span data (especiallyduration_ms) is mirrored into tags and used to backdatestartTimefor p95 charts.withTracetreats Sentry/adapter rejections as best-effort sogetAssetsforce updates andhandleAssetsUpdatestill complete.Nested spans & session gating — Fetch and update pipelines wrap work in parent spans (
AssetsFetchPipeline,AssetsBackgroundFetch,AssetsUpdateEnrichment); per-source timings and summary spans (AssetsFullFetch,AssetsControllerFirstInitFetch,AssetsUpdatePipeline, etc.) nest viaparentContext. Fast and background fetch lanes are siblingwithTracecalls, not nested. Pipeline, data-source, and enrichment spans emit only until the firstforceUpdatein an unlock session (#firstInitFetchReported); later polls, force refreshes, and subscription enrichment skip those spans (reset on lock/#stop).Balance selector —
calculateBalanceForAllWalletsemits oneAggregatedBalance/AggregatedBalanceSelectorpair for the full wallet pass instead of a root span per account group.Reviewed by Cursor Bugbot for commit 7001768. Bugbot is set up for automated code reviews on this repo. Configure here.