feat: forward duration and traceId to RPC Service Degraded segment events - #29964
Conversation
|
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. |
|
Review the following changes in direct dependencies. Learn more about Socket for GitHub.
|
…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.
3466c39 to
9ba77f6
Compare
…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.
@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.
@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.
|
@metamaskbot update-mobile-fixture |
|
🔄 Fixture update started. Running workflow from branch |
|
❌ 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 |
|
@metamaskbot update-mobile-fixture |
|
🔄 Fixture update started. Running workflow from branch |
|
❌ 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 |
|
@metamaskbot update-mobile-fixture |
|
🔄 Fixture update started. Running workflow from branch |
|
❌ 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 |
🔍 Smart E2E Test Selection
click to see 🤖 AI reasoning detailsE2E Test Selection: Performance Test Selection: |
|



Description
Bumps
@metamask/network-controllerto^31.0.0and@metamask/controller-utilsto^12.0.0, which introduce two new optional payload fields onNetworkController:rpcEndpointDegraded(and…ChainDegraded):duration(number | undefined): the policy execution time in milliseconds when the request succeeded but exceeded the degraded threshold.undefinedwhen retries were exhausted.traceId(string | undefined): the value of theX-Trace-Idresponse header from the last request attempt.undefinedwhen no response was received or the header was absent.This PR threads both fields through
onRpcEndpointDegraded→trackRpcEndpointEventand emits them on theRPC Service DegradedSegment event asduration_msandtrace_id(snake_case, to match existing properties such asrpc_method_nameandretry_reason). Both keys are conditionally omitted from the event when the upstream value isundefined, so we don't pollute Segment with empty values.A
resolutionsentry pins@metamask/network-controllerto31.0.0repo-wide to dedupe the nested copy that@metamask/multichain-network-controller@^3.1.0still pulls in at^30.1.0. Without this dedupe, TypeScript reports nominal-type mismatches across packages that consumeNetworkConfiguration/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)
Pre-merge reviewer checklist
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:rpcEndpointDegradedsubscription forwards optionaldurationandtraceIdintoonRpcEndpointDegraded/trackRpcEndpointEvent, emitting them to Segment asduration_msandtrace_idonly when defined, with new unit tests covering both presence and omission.Dependency + fixture updates. Bumps/pins
@metamask/network-controllerto31.0.0(pluscontroller-utilsandremote-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.