MetaMask / MetaMask/metamask-extension

[P3] Integration test for Sentry distributed-trace propagation (flag-gated + target-scoped)

Open
#44,053 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

INVALID-ISSUE-TEMPLATE ta-triaged
Dominant language
TypeScript
Stars
13.2k
Forks
5.6k
Avg merge
2d 5h
Merged PRs (30d)
451

Description

**File:** `app/scripts/lib/sentry-trace-propagation.ts`, `app/scripts/lib/setupSentry.js`
**Size:** M

---

## Problem

PR #42867 (Sentry v8→v10) enabled native W3C `traceparent` propagation (`propagateTraceparent: true`), gated on the `SENTRY_DISTRIBUTED_TRACING_ENABLED` kill switch and scoped to `BACKEND_TRACE_PROPAGATION_TARGETS` (`*.api.cx.metamask.io`). The unit test added for it only asserted that `Sentry.init` received `propagateTraceparent: true` — mock-heavy, high-maintenance, and not covering the behavior that actually matters (flag-gating and target-scoping). It was removed during review.

---

## Solution

Add an integration (or e2e) test that drives the real init path and asserts outbound-header behavior, rather than mocking `Sentry.init`.

---

## Acceptance Criteria

- [ ] With distributed tracing enabled, outbound requests to backend targets (`*.api.cx.metamask.io`) carry exactly one `traceparent`, alongside `sentry-trace` / `baggage` and the RAPID `baggage` segment.
- [ ] With the kill switch (`SENTRY_DISTRIBUTED_TRACING_DISABLED`), no `traceparent` is injected to those targets.
- [ ] Non-backend hosts never receive `traceparent`.

---

## Notes

The #43819 coverage harness already exercises the real init path and captures emitted envelopes; this ticket is specifically for the targeted outbound-header assertions (gating + scoping) that the removed unit test failed to cover.

---

## Labels

`team-extension-platform`, `area-sentry`

---

## References

- PR #42867 (Sentry v8→v10 upgrade)
- #43819 (coverage-equivalence harness)

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with app/scripts/lib/sentry-trace-propagation.ts and app/scripts/lib/setupSentry.js, then read the #43819 coverage-equivalence harness to see how the real init path and emitted traffic are exercised. Add targeted outbound-header assertions for enabled and disabled tracing, backend targets, and non-backend hosts; done means the acceptance criteria pass without mocking Sentry.init.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, typescript
Domain
api, testing
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.