Skip to content

feat: forward duration and traceId to RPC Service Degraded segment events - #29964

Merged
cryptodev-2s merged 14 commits into
mainfrom
chore/bump-network-controller-v31
May 13, 2026
Merged

cryptodev-2s merged 14 commits into
mainfrom
chore/bump-network-controller-v31

Conversation

@cryptodev-2s

@cryptodev-2s cryptodev-2s commented May 11, 2026 •

Copy link
Copy Markdown
Contributor

Description

Bumps @metamask/network-controller to ^31.0.0 and @metamask/controller-utils to ^12.0.0, which introduce two new optional payload fields on NetworkController:rpcEndpointDegraded (and …ChainDegraded):

  • duration (number | undefined): the policy execution time in milliseconds when the request succeeded but exceeded the degraded threshold. undefined when retries were exhausted.
  • traceId (string | undefined): the value of the X-Trace-Id response header from the last request attempt. undefined when no response was received or the header was absent.

This PR threads both fields through onRpcEndpointDegraded → trackRpcEndpointEvent and emits them on the RPC Service Degraded Segment event as duration_ms and trace_id (snake_case, to match existing properties such as rpc_method_name and retry_reason). Both keys are conditionally omitted from the event when the upstream value is undefined, so we don't pollute Segment with empty values.

A resolutions entry pins @metamask/network-controller to 31.0.0 repo-wide to dedupe the nested copy that @metamask/multichain-network-controller@^3.1.0 still pulls in at ^30.1.0. Without this dedupe, TypeScript reports nominal-type mismatches across packages that consume NetworkConfiguration / NetworkState (e.g. transaction-controller-init.ts, assets-list.ts). The runtime change in 31.0.0 is additive only (two optional payload fields), so forcing the multichain dep onto the newer version is safe.

This enables correlating degraded RPC events with backend traces for debugging RPC health, and surfaces the actual slow-success latency.

See core PR MetaMask/core#8455 for the upstream change.

Changelog

CHANGELOG entry: null

Related issues

Fixes: WPC-963

Manual testing steps

```gherkin
Feature: RPC degraded events carry duration and trace ID

Scenario: slow but successful RPC request emits duration_ms and trace_id
Given a network whose RPC endpoint responds slowly (>5s) and returns an X-Trace-Id header
And MetaMetrics is enabled
When the user performs an action that issues a JSON-RPC call (e.g. switching chains, refreshing balances)
Then the outgoing "RPC Service Degraded" Segment event contains numeric duration_ms
And the event contains trace_id equal to the response's X-Trace-Id header

Scenario: retries-exhausted RPC request omits duration_ms
Given a network whose RPC endpoint returns retriable errors (e.g. 503) for every attempt
And MetaMetrics is enabled
When the user performs an action that issues a JSON-RPC call
Then the outgoing "RPC Service Degraded" Segment event omits the duration_ms property
And the event includes trace_id only if a response with X-Trace-Id was received before failing
```

Screenshots/Recordings

N/A — no UI change.

Before

After

Pre-merge author checklist

Performance checks (if applicable)

  • I've tested on Android
  • I've tested with a power user scenario
  • I've instrumented key operations with Sentry traces for production performance metrics

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.

Note

Medium Risk
Touches network telemetry wiring and analytics event payloads; low functional impact, but mistakes could break/alter Segment schema and degrade monitoring quality.

Overview
RPC degraded telemetry now includes more context. The NetworkController:rpcEndpointDegraded subscription forwards optional duration and traceId into onRpcEndpointDegraded/trackRpcEndpointEvent, emitting them to Segment as duration_ms and trace_id only when defined, with new unit tests covering both presence and omission.

Dependency + fixture updates. Bumps/pins @metamask/network-controller to 31.0.0 (plus controller-utils and remote-feature-flag-controller), adds new default network entries (Avalanche, Monad Mainnet, MegaETH Mainnet, ZKsync Era) to test background state and updates Infura API mocks and AddressSelector sorting expectations accordingly.

Reviewed by Cursor Bugbot for commit 73534c4. Bugbot is set up for automated code reviews on this repo. Configure here.

@github-actions

Copy link
Copy Markdown
Contributor

CLA Signature Action: All authors have signed the CLA. You may need to manually re-run the blocking PR check if it doesn't pass in a few minutes.

@metamaskbotv2 metamaskbotv2 Bot added the team-core-platform Core Platform team label May 11, 2026
@cryptodev-2s
cryptodev-2s marked this pull request as ready for review May 11, 2026 11:14
@socket-security

socket-security Bot commented May 11, 2026 •

Copy link
Copy Markdown

Review the following changes in direct dependencies. Learn more about Socket for GitHub.

Diff Package Supply Chain
Security
Vulnerability Quality Maintenance License
Updatednpm/​@​metamask/​remote-feature-flag-controller@​4.2.0 ⏵ 4.2.1991007694 +2100

View full report

…ents

Bumps @metamask/network-controller to ^31.0.0 (with a resolution to
dedupe the nested copy pulled in by @metamask/multichain-network-controller)
and @metamask/controller-utils to ^12.0.0, and threads the new optional
duration and traceId fields from NetworkController:rpcEndpointDegraded
through to the Segment event as duration_ms and trace_id.
@cryptodev-2s
cryptodev-2s force-pushed the chore/bump-network-controller-v31 branch from 3466c39 to 9ba77f6 Compare May 11, 2026 11:25
…ils@12 compatibility

4.2.0 requires controller-utils@^11.19.0, which forces yarn to install a
nested 11.x copy alongside our bumped 12.0.0 root. The nested copy then
fails inside Jest with 'createProjectLogger is not a function'. 4.2.1
requires controller-utils@^12.0.0, so a single root resolution is used.
@metamask/controller-utils@12.0.0 adds monad-mainnet, megaeth-mainnet,
avalanche-mainnet, and zksync-mainnet to the default Infura networks.
The Engine 'matches initial state fixture' assertion compares against
this JSON snapshot, so the four new chains need to be included.
@github-actions github-actions Bot added size-M and removed size-S labels May 11, 2026
@metamask/controller-utils@12.0.0 added monad-mainnet, megaeth-mainnet,
avalanche-mainnet, and zksync-mainnet to the default state. They now
appear in the EVM-only network list alongside the existing chains, so
extend the expected array accordingly.
@cryptodev-2s cryptodev-2s self-assigned this May 11, 2026
@cryptodev-2s
cryptodev-2s requested a review from a team May 11, 2026 17:00
cryptodev-2s and others added 2 commits May 11, 2026 19:28
@metamask/controller-utils@12.0.0 added monad-mainnet, megaeth-mainnet,
and zksync-mainnet to the default Infura set. NetworkController now
initializes RPC clients for them at post-onboarding, hitting Infura
endpoints that the E2E mock framework treats as unmocked. Allowlist the
three endpoints alongside the existing avalanche-mainnet entry.
@cryptodev-2s
cryptodev-2s requested a review from a team as a code owner May 11, 2026 18:51
@cryptodev-2s

Copy link
Copy Markdown
Contributor Author

@metamaskbot update-mobile-fixture

@github-actions

Copy link
Copy Markdown
Contributor

🔄 Fixture update started. Running workflow from branch chore/bump-network-controller-v31. View workflow runs

@github-actions

Copy link
Copy Markdown
Contributor

❌ E2E fixture update failed.\n\nCommon causes:\n- CI workflow is still running — wait for 'Build iOS Apps' to complete\n- CI workflow was skipped — ensure your PR has iOS-impacting changes or use skip-smart-e2e-selection label\n- iOS build failed — check the CI workflow for errors\n\nView logs and retry

@cryptodev-2s

Copy link
Copy Markdown
Contributor Author

@metamaskbot update-mobile-fixture

@github-actions

Copy link
Copy Markdown
Contributor

🔄 Fixture update started. Running workflow from branch chore/bump-network-controller-v31. View workflow runs

@github-actions

Copy link
Copy Markdown
Contributor

❌ E2E fixture update failed.\n\nCommon causes:\n- CI workflow is still running — wait for 'Build iOS Apps' to complete\n- CI workflow was skipped — ensure your PR has iOS-impacting changes or use skip-smart-e2e-selection label\n- iOS build failed — check the CI workflow for errors\n\nView logs and retry

@cryptodev-2s

Copy link
Copy Markdown
Contributor Author

@metamaskbot update-mobile-fixture

@github-actions

Copy link
Copy Markdown
Contributor

🔄 Fixture update started. Running workflow from branch chore/bump-network-controller-v31. View workflow runs

@github-actions

Copy link
Copy Markdown
Contributor

❌ E2E fixture update failed.\n\nCommon causes:\n- CI workflow is still running — wait for 'Build iOS Apps' to complete\n- CI workflow was skipped — ensure your PR has iOS-impacting changes or use skip-smart-e2e-selection label\n- iOS build failed — check the CI workflow for errors\n\nView logs and retry

@github-actions

Copy link
Copy Markdown
Contributor

🔍 Smart E2E Test Selection

  • Selected E2E tags: SmokeAccounts, SmokeConfirmations, SmokeIdentity, SmokeNetworkAbstractions, SmokeNetworkExpansion, SmokeSwap, SmokeStake, SmokeWalletPlatform, SmokeMoney, SmokePerps, SmokeMultiChainAPI, SmokePredictions, SmokeSeedlessOnboarding, SmokeBrowser, SmokeSnaps
  • Selected Performance tags: @PerformanceAccountList, @PerformanceOnboarding, @PerformanceLogin, @PerformanceSwaps, @PerformanceLaunch, @PerformanceAssetLoading, @PerformancePredict, @PerformancePreps
  • Risk Level: high
  • AI Confidence: 100%
click to see 🤖 AI reasoning details

E2E Test Selection:
Hard rule (controller-version-update): @MetaMask controller package version updated in package.json: @metamask/network-controller, @metamask/controller-utils, @metamask/remote-feature-flag-controller. Running all tests.

Performance Test Selection:
Hard rule (controller-version-update): @MetaMask controller package version updated in package.json: @metamask/network-controller, @metamask/controller-utils, @metamask/remote-feature-flag-controller. Running all tests.

View GitHub Actions results

@sonarqubecloud

Copy link
Copy Markdown

@cryptodev-2s
cryptodev-2s added this pull request to the merge queue May 13, 2026
Merged via the queue into main with commit d4d4dfa May 13, 2026
116 checks passed
@cryptodev-2s
cryptodev-2s deleted the chore/bump-network-controller-v31 branch May 13, 2026 10:33
@github-actions github-actions Bot locked and limited conversation to collaborators May 13, 2026
@metamaskbotv2 metamaskbotv2 Bot added the release-7.78.0 Issue or pull request that will be included in release 7.78.0 label May 13, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

release-7.78.0 Issue or pull request that will be included in release 7.78.0 size-M team-core-platform Core Platform team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants