feat: forward duration and traceId to RPC Service Degraded segment events#42569
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.
|
|
@metamaskbot update-policies |
|
Policies updated. Tip Follow the policy review process outlined in the LavaMoat Policy Review Process doc before expecting an approval from Policy Reviewers. 👀 lavamoat/browserify/beta/policy.json changes differ from lavamoat/browserify/main/policy.json changes |
Builds ready [e5080d5]
⚡ Performance Benchmarks (Total: 🟢 15 pass · 🟡 9 warn · 🔴 0 fail)
Bundle size diffs [🚨 Warning! Bundle size has increased!]
|
|
@metamaskbot update-policies |
|
LavaMoat validation was skipped in CI. Policies were not checked for this commit. |
|
@metamaskbot update-policies |
|
LavaMoat validation is still running. Please retry |
|
@metamaskbot update-policies |
|
Policies updated. Tip Follow the policy review process outlined in the LavaMoat Policy Review Process doc before expecting an approval from Policy Reviewers. 👀 lavamoat/browserify/beta/policy.json changes differ from lavamoat/browserify/main/policy.json changes |
Builds ready [7470695]
⚡ Performance Benchmarks (Total: 🟢 14 pass · 🟡 10 warn · 🔴 0 fail)
Bundle size diffs [🚨 Warning! Bundle size has increased!]
|
Builds ready [54e5e11] [reused from 6c2207e]
⚡ Performance Benchmarks (Total: 🟢 7 pass · 🟡 0 warn · 🔴 0 fail)
Bundle size diffs [🚨 Warning! Bundle size has increased!]
|
|
@metamaskbot update-policies |
|
LavaMoat validation failed but no policy diffs were produced (the validation job may have crashed before generating diffs). Failed jobs:
|
|
@metamaskbot update-policies |
Builds ready [34f4ae8] [reused from c9e4add]
⚡ Performance Benchmarks (Total: 🟢 14 pass · 🟡 10 warn · 🔴 0 fail)
Bundle size diffs [🚨 Warning! Bundle size has increased!]
|
…ents Bumps @metamask/network-controller to ^32.0.0, @metamask/controller-utils to ^12.1.0, and @metamask/connectivity-controller to ^0.2.0. Threads the new optional duration and traceId fields from NetworkController:rpcEndpointDegraded through to the Segment event as duration_ms and trace_id. Adapter side-effect: connectivity-controller@0.2.0 made ConnectivityAdapter.getStatus() async, so ExtensionConnectivityAdapter now returns Promise<ConnectivityStatus>. The default-state semantics are unchanged (adapter and controller both default to 'online'). The NetworkControllerInit snapshot picks up Monad Mainnet as a new default Infura network from controller-utils@12.1.
@metamask/controller-utils@12.1.0 adds monad-mainnet to the default Infura networks set. The new chain shows up in the initial state without a failover URL, so it belongs in networksWithoutFailoverUrls.
@metamask/controller-utils@12.1.0 adds Monad Mainnet to the default Infura networks. NetworkController hits monad-mainnet.infura.io during the fixture-validation E2E test; add the host to the snapshot.
@metamask/controller-utils@12.1.0 adds Monad Mainnet to the default Infura networks set, so it's now part of the EVM popular networks auto-granted on EIP-1193 connect. - network-controller-init: override Monad's name to 'Monad' to match the existing friendly-name pattern (Ethereum, Linea, Base, ...). - multiple-provider-connections: bump connected-network count 8 -> 9 and add MONAD_DISPLAY_NAME to the displayed-network assertion. - edit-networks-permissions: bump post-Mainnet-disconnect count 7 -> 8. - network-controller-init snapshot: regenerated with the new name.
The MONAD_DISPLAY_NAME constant is 'Monad', matching the friendly-name override in network-controller-init.ts. However, that override only fires when no persistedState is provided (onboarding flow). E2E tests use FixtureBuilderV2 which provides persistedState, so the override is skipped and the chain inherits the upstream NetworkNickname 'Monad Mainnet' when NetworkController augments runtime state with the new default Infura networks. Match what the modal's data-testid actually renders.
CurrencyRateController now seeds an MON entry at runtime because @metamask/controller-utils@12.1.0 added Monad Mainnet (native MON) to the default Infura networks. The errors.spec background-state deep-equal assertions need the MON rate in the expected state.
…lowlist NetworkController initializes Monad Mainnet during onboarding now that controller-utils@12.1.0 added it to the default Infura networks set; the Maximum Privacy Settings test expects no network calls outside the allowlist.
e11c8f2 to
829bc6a
Compare
✨ Files requiring CODEOWNER review ✨👨🔧 @MetaMask/extension-platform (1 files, +18 -0)
🕵️ @MetaMask/extension-privacy-reviewers (2 files, +2 -0)
📜 @MetaMask/policy-reviewers (12 files, +4124 -396)
Tip Follow the policy review process outlined in the LavaMoat Policy Review Process doc before expecting an approval from Policy Reviewers. 🧪 @MetaMask/qa (2 files, +19 -0)
|
1 similar comment
✨ Files requiring CODEOWNER review ✨👨🔧 @MetaMask/extension-platform (1 files, +18 -0)
🕵️ @MetaMask/extension-privacy-reviewers (2 files, +2 -0)
📜 @MetaMask/policy-reviewers (12 files, +4124 -396)
Tip Follow the policy review process outlined in the LavaMoat Policy Review Process doc before expecting an approval from Policy Reviewers. 🧪 @MetaMask/qa (2 files, +19 -0)
|
network-controller-init.ts renames Monad Mainnet to 'Monad' during the fresh-onboarding flow (alongside Ethereum/Linea/Base/etc.), so the wallet-fixture-validation E2E observes name='Monad'. Sync both fixture files to match.
✨ Files requiring CODEOWNER review ✨👨🔧 @MetaMask/extension-platform (1 files, +18 -0)
🕵️ @MetaMask/extension-privacy-reviewers (2 files, +2 -0)
📜 @MetaMask/policy-reviewers (12 files, +4124 -396)
Tip Follow the policy review process outlined in the LavaMoat Policy Review Process doc before expecting an approval from Policy Reviewers. 🧪 @MetaMask/qa (2 files, +19 -0)
|
Builds ready [e4d4742] [reused from 829bc6a]
⚡ Performance Benchmarks (Total: 🟢 12 pass · 🟡 9 warn · 🔴 0 fail)
Bundle size diffs [🚨 Warning! Bundle size has increased!]
|
…rtions Now that the wallet fixtures carry name='Monad' (matching the network-controller-init.ts override), the modal's data-testid resolves to 'Monad'. Use the existing display-name constant instead of the upstream-derived 'Monad Mainnet' literal.
✨ Files requiring CODEOWNER review ✨👨🔧 @MetaMask/extension-platform (1 files, +18 -0)
🕵️ @MetaMask/extension-privacy-reviewers (2 files, +2 -0)
📜 @MetaMask/policy-reviewers (12 files, +4124 -396)
Tip Follow the policy review process outlined in the LavaMoat Policy Review Process doc before expecting an approval from Policy Reviewers. 🧪 @MetaMask/qa (2 files, +19 -0)
|
Builds ready [5480377] [reused from 829bc6a]
⚡ Performance Benchmarks (Total: 🟢 12 pass · 🟡 9 warn · 🔴 0 fail)
Bundle size diffs [🚨 Warning! Bundle size has increased!]
|
There was a problem hiding this comment.
The addition of Monad is expected, as it was requested by the Money team: https://consensyssoftware.atlassian.net/browse/MUSD-784
mcmire
left a comment
There was a problem hiding this comment.
Policy changes look OK, but I had comments about the rest of the PR below.
| "@metamask/bridge-status-controller": "71.1.1", | ||
| "@metamask/messenger@npm:^0.3.0": "^1.2.0", | ||
| "@metamask/network-controller": "30.0.1", | ||
| "@metamask/network-controller": "32.0.0", |
There was a problem hiding this comment.
Hmm, I didn't realize we had a resolution for network-controller. Can we get rid of this?
| "@metamask/network-controller": "32.0.0", |
There was a problem hiding this comment.
I am not sure why this was added I have a following PR that is focused on bumping packages and removing this and other resolutions.
Omission is already covered by the existing 'calls trackEvent with the
correct parameters' test on line ~210, which uses
toHaveBeenCalledWith({...}) with a strict properties object that does
not include duration_ms or trace_id.
✨ Files requiring CODEOWNER review ✨👨🔧 @MetaMask/extension-platform (1 files, +18 -0)
🕵️ @MetaMask/extension-privacy-reviewers (2 files, +2 -0)
📜 @MetaMask/policy-reviewers (12 files, +4124 -396)
Tip Follow the policy review process outlined in the LavaMoat Policy Review Process doc before expecting an approval from Policy Reviewers. 🧪 @MetaMask/qa (2 files, +19 -0)
|
Builds ready [290dee7] [reused from 829bc6a]
⚡ Performance Benchmarks (Total: 🟢 12 pass · 🟡 9 warn · 🔴 0 fail)
Bundle size diffs [🚨 Warning! Bundle size has increased!]
|
|



Description
Bumps
@metamask/network-controllerto^32.0.0,@metamask/controller-utilsto^12.1.0, and@metamask/connectivity-controllerto^0.2.0(transitive requirement of network-controller@32). Threads the new optionaldurationandtraceIdfields from theNetworkController:rpcEndpointDegraded(and…ChainDegraded) event payloads through to the SegmentRPC Service Degradedevent asduration_msandtrace_id.Payload semantics
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.Both fields are conditionally omitted from the Segment event when the upstream value is
undefined(we use=== undefinedrather than truthy-style checks: adurationvalue of0is technically valid, and fortraceIdempty string is distinguishable from "not present"). Segment property names use snake_case to match the existingrpc_method_name,retry_reason, etc.This enables correlating degraded RPC events with backend traces for debugging RPC health, and surfaces actual slow-success latency.
Side effects from the dependency bumps
@metamask/connectivity-controller@0.2.0madeConnectivityAdapter.getStatus()async (core#7679).ExtensionConnectivityAdapter.getStatus()now returnsPromise<ConnectivityStatus>; its existing testsawaitthe call.setConnectivityStatus), and the controller's new default state ('online') matches the adapter's initial state.@metamask/controller-utils@12.1.0added Monad Mainnet (0x8f) to the default Infura networks set (core#8680).network-controller-init.tsextends the existing friendly-name override list withnetworks[CHAIN_IDS.MONAD].name = 'Monad'(alongside Ethereum/Linea/Base/Arbitrum/BSC/OP/Polygon).default-fixture.json,onboarding-fixture.json) include a Monad entry with the overridden name.privacy-snapshot.jsonandtest/e2e/tests/privacy/privacy-max-allowlist-onboarding.jsonallowlistmonad-mainnet.infura.io.metamask-controller.test.jsincludes0x8finnetworksWithoutFailoverUrls.errors.spec.tsbackground-state snapshots includeMONinCurrencyController.currencyRates.multiple-provider-connections.spec.tsbumps EVM popular-networks count8 → 9and addsMONAD_DISPLAY_NAMEto the displayed-network assertions;edit-networks-permissions.spec.tsbumps post-Mainnet-disconnect count7 → 8.NetworkControllerInitinline snapshot updated.See upstream core PR MetaMask/core#8455 for the
duration/traceIdchange.Changelog
CHANGELOG entry: null
Related issues
Fixes: WPC-963 and MUSD-784
Manual testing steps
RPC Service Degradedevent:duration_msis present (a number) andtrace_idis present when the endpoint setsX-Trace-Id.duration_msis omitted;trace_idis present if the failing response carried the header, otherwise omitted.Screenshots/Recordings
N/A — no UI change.
Before
After
Pre-merge author checklist
Pre-merge reviewer checklist
Note
Medium Risk
Medium risk because it changes telemetry payload construction for degraded RPC events and threads new fields through the network controller init path; it also updates default network initialization (adds Monad mainnet) and adjusts connectivity adapter API to be async, which could affect consumers if mismatched.
Overview
Adds richer telemetry for degraded RPC endpoints.
onRpcEndpointDegraded/trackRpcEndpointEventnow accept optionaldurationandtraceIdand include them in the SegmentRPC Service Degradedevent asduration_msandtrace_idonly when explicitly present.Wires the new degraded-event fields through initialization and updates tests.
NetworkControllerInitforwardsduration/traceIdfrom theNetworkController:rpcEndpointDegradedmessenger payload, adds Monad mainnet (0x8f) to the default network naming snapshot, and updates the extension connectivity adaptergetStatusto beasync(with tests updated toawait).Updates LavaMoat policies. The
policy.jsonfiles are refreshed to reflect updated package dependency paths (notably around@metamask/controller-utils).Reviewed by Cursor Bugbot for commit 290dee7. Bugbot is set up for automated code reviews on this repo. Configure here.