MetaMask / MetaMask/metamask-extension
[P2] Restore and re-optimize global `tracesSampleRate` once dynamic sampling controls ship
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 13.2k
- Forks
- 5.6k
- Avg merge
- 2d 5h
- Merged PRs (30d)
- 451
Description
**Parent Epic:** [#43410 - Sentry Quota Breach: Extension Telemetry](https://github.com/MetaMask/metamask-extension/issues/43410)
**File:** `app/scripts/lib/setupSentry.js`
**Size:** M
---
## Problem
The global `tracesSampleRate` is held low (0.75%, cut to 0.5% during the July 2026 incident as interim headroom) as blunt insurance against unknown hot-path offenders. Without a way to throttle a specific transaction without a release, the only safe global rate is a low one, which suppresses telemetry fidelity on the healthy majority to protect against a worst case. Three incidents in eight weeks (#43211, multichain #43633, #44447) each ran roughly a week before being named, so the defensive-low posture is presently justified.
Remote-flag traffic control ([MetaMask-planning#7361](https://github.com/MetaMask/MetaMask-planning/issues/7361): per-release ceiling #7359, per-transaction-name overrides #7360) decouples the global rate from worst-case-offender risk. An offender can be throttled by name without a release, and the rate becomes a reversible dial rather than static insurance. This ticket tracks restoring the rate from the interim 0.5%, and then raising it for fidelity, once the enabling conditions hold.
---
## Conditions (all required before raising)
1. **Dynamic controls shipped.** The remote flag ([MetaMask-planning#7361](https://github.com/MetaMask/MetaMask-planning/issues/7361)), the autonomous per-transaction-name budget (#44452), and per-name volume detection (#43411). The flag is manual and lags roughly a week; the budget is the automatic floor; the alert is the trigger. Together they make a higher rate safe. The flag alone re-exposes the same week-long windows that caused all three incidents, at higher cost.
2. **Structural offenders fixed and drained.** #44447 (`AggregatedBalanceSelector`), [MetaMask-planning#7354](https://github.com/MetaMask/MetaMask-planning/issues/7354) / [#7366](https://github.com/MetaMask/MetaMask-planning/issues/7366) (service-worker cold-start and mega-trace volume), #43633 (residual multichain). The healthy baseline must be measured after these drain, because that baseline is what the rate multiplies.
3. **Allocated slice sized for the target.** `target_rate ≤ allocated perf-unit slice ÷ healthy-baseline volume at rate 1.0`. The original 0.75% was itself a quota-constrained compromise, likely below fidelity-optimal.
---
## End state
Per-transaction-name rate-shaping via #7360, not a single global dial. Sample high-value transactions (UI Startup, real user flows) richer and noisy-but-necessary ones leaner, with the global rate as the default for everything unspecified. This yields more fidelity per unit of budget than any flat global increase.
---
## Acceptance Criteria
- [ ] Global `tracesSampleRate` restored from the interim 0.5% once the structural offenders drain and the slice fits.
- [ ] Any raise above the historical 0.75% gated behind #7361 + #44452 + #43411 shipped.
- [ ] High-value transactions sampled at a higher per-name rate than noisy ones (#7360), not a single flat rate.
- [ ] Consumption stays within the allocated slice at the new rate; the reversible per-release ceiling (#7359) is configured as the backstop.
---
## Out of scope
Errors are a separate axis. Errors are sent at 100% (no client `sampleRate`) and roughly 95% are rate-limited (`key_quota` + `project_quota_error_usage_exceeded`); the trace rate does not touch them. A separate error `sampleRate` decision is tracked elsewhere.
---
## Labels
`team-extension-platform`, `area-sentry`
---
## Dependencies
**Depends on:** [MetaMask-planning#7361](https://github.com/MetaMask/MetaMask-planning/issues/7361) (remote flag), #44452 (autonomous budget), #43411 (per-name detection), #44447 + [MetaMask-planning#7354](https://github.com/MetaMask/MetaMask-planning/issues/7354) (offenders fixed and drained).
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with app/scripts/lib/setupSentry.js and inspect the current global tracesSampleRate configuration. Review the dependencies #7361, #44452, #43411, #44447, #43633, and the linked planning issues before changing the rate. Done means the structural offenders are drained, the allocated slice supports the target, per-name shaping and the reversible ceiling are configured, and consumption remains within budget.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- observability
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100