feat: add rpc_method_name, type and retry_reason to degraded RPC endpoint Segment events#26187
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. |
2fb9fb4 to
b73455a
Compare
|
Review the following changes in direct dependencies. Learn more about Socket for GitHub.
|
693269a to
1ed19e7
Compare
rpcMethodName to degraded and unavailable RPC endpoint Segment events
rpcMethodName to degraded and unavailable RPC endpoint Segment eventsrpcMethodName to degraded RPC endpoint Segment events
mcmire
left a comment
There was a problem hiding this comment.
Looks good when network-controller is released.
Remember that we will need to update the segment-schema repo with the new property before we merge this: https://github.com/Consensys/segment-schema/blob/f961385ccfa021c9588d060fabe3ef3e784ad88f/libraries/events/metamask-network/rpc-service-degraded.yaml
## Explanation RPC endpoint degraded events (`NetworkController:rpcEndpointDegraded` and it's chain-level variant) now include `rpcMethodName` in their payloads. This identifies which JSON-RPC method was being executed when the endpoint became degraded, enabling better debugging of RPC health issues. The method name is captured in `RpcService` via `#currentRpcMethodName`, set in the `finally` block of the Cockatiel policy's `execute` callback to minimise the race window between the write and Cockatiel's synchronous event dispatch. ## References Fixes: https://consensyssoftware.atlassian.net/browse/WPC-441 * Extension consumer PR: MetaMask/metamask-extension#40176 * Mobile consumer PR: MetaMask/metamask-mobile#26187 <!-- Are there any issues that this pull request is tied to? Are there other links that reviewers should consult to understand these changes better? Are there client or consumer pull requests to adopt any breaking changes? For example: * Fixes #12345 * Related to #67890 --> ## Checklist - [ ] I've updated the test suite for new or updated code as appropriate - [ ] I've updated documentation (JSDoc, Markdown, etc.) for new or updated code as appropriate - [ ] I've communicated my changes to consumers by [updating changelogs for packages I've changed](https://github.com/MetaMask/core/tree/main/docs/processes/updating-changelogs.md) - [ ] I've introduced [breaking changes](https://github.com/MetaMask/core/tree/main/docs/processes/breaking-changes.md) in this PR and have prepared draft pull requests for clients and consumer packages to resolve them <!-- CURSOR_SUMMARY --> --- > [!NOTE] > **Medium Risk** > Introduces a breaking type change and modifies degraded-event emission data in the RPC service layer; low behavioral risk but could break downstream implementors and any logic that depends on exact event payloads. > > **Overview** > `NetworkController:rpcEndpointDegraded` and `NetworkController:rpcEndpointChainDegraded` events now include a `rpcMethodName` field so consumers can identify which JSON-RPC method was executing when degradation (slow request / retry exhaustion) occurred. > > This threads the method name from `RpcService.request` through `RpcService.onDegraded` and into `create-network-client`’s published messenger events, updates the `RpcServiceRequestable.onDegraded` listener type (**breaking**), and expands test coverage (including concurrent-request and “first method triggers degraded” scenarios). > > <sup>Written by [Cursor Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit c756c02. This will update automatically on new commits. Configure [here](https://cursor.com/dashboard?tab=bugbot).</sup> <!-- /CURSOR_SUMMARY -->
## Explanation RPC endpoint degraded events (`NetworkController:rpcEndpointDegraded` and it's chain-level variant) now include `rpcMethodName` in their payloads. This identifies which JSON-RPC method was being executed when the endpoint became degraded, enabling better debugging of RPC health issues. The method name is captured in `RpcService` via `#currentRpcMethodName`, set in the `finally` block of the Cockatiel policy's `execute` callback to minimise the race window between the write and Cockatiel's synchronous event dispatch. ## References Fixes: https://consensyssoftware.atlassian.net/browse/WPC-441 * Extension consumer PR: MetaMask/metamask-extension#40176 * Mobile consumer PR: MetaMask/metamask-mobile#26187 <!-- Are there any issues that this pull request is tied to? Are there other links that reviewers should consult to understand these changes better? Are there client or consumer pull requests to adopt any breaking changes? For example: * Fixes #12345 * Related to #67890 --> ## Checklist - [ ] I've updated the test suite for new or updated code as appropriate - [ ] I've updated documentation (JSDoc, Markdown, etc.) for new or updated code as appropriate - [ ] I've communicated my changes to consumers by [updating changelogs for packages I've changed](https://github.com/MetaMask/core/tree/main/docs/processes/updating-changelogs.md) - [ ] I've introduced [breaking changes](https://github.com/MetaMask/core/tree/main/docs/processes/breaking-changes.md) in this PR and have prepared draft pull requests for clients and consumer packages to resolve them <!-- CURSOR_SUMMARY --> --- > [!NOTE] > **Medium Risk** > Moderate risk because it changes a public TypeScript listener signature (breaking) and adjusts degraded-event emission timing to handle concurrency; runtime behavior should otherwise be unchanged. > > **Overview** > Adds `rpcMethodName` to degraded telemetry: `NetworkController:rpcEndpointDegraded` and `NetworkController:rpcEndpointChainDegraded` payloads now include the JSON-RPC method that was executing when degradation was detected. > > This is implemented by having `RpcService` track the last-completed request’s method and attach it to `onDegraded` emissions, with `create-network-client` forwarding it through to messenger events; types and tests are updated accordingly, and the `RpcServiceRequestable.onDegraded` listener signature is **breaking** due to the new required field. > > <sup>Written by [Cursor Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit 4f6e17a. This will update automatically on new commits. Configure [here](https://cursor.com/dashboard?tab=bugbot).</sup> <!-- /CURSOR_SUMMARY -->
rpcMethodName to degraded RPC endpoint Segment eventsrpc_method_name, degraded_event_type and retry_reason to degraded RPC endpoint Segment events
ae02d91 to
2f65d10
Compare
f45bc2f to
89a4510
Compare
app/core/Engine/controllers/network-controller/messenger-action-handlers.ts
Outdated
Show resolved
Hide resolved
rpc_method_name, degraded_event_type and retry_reason to degraded RPC endpoint Segment eventsrpc_method_name, type and retry_reason to degraded RPC endpoint Segment events
🔍 Smart E2E Test Selection
click to see 🤖 AI reasoning detailsE2E Test Selection: Performance Test Selection: |
|



Description
Add
rpc_method_name,typeandretry_reasonto theRPC Service DegradedSegment events. This lets us identify which JSON-RPC methods produce the most slow requests or retry exhaustions, enabling better debugging of RPC endpoint health issues.Consumes the new
rpcMethodName,typeandretryReasonfield added toNetworkController:rpcEndpointDegradedevents in@metamask/network-controller(core PR #7954, #7988).Changelog
CHANGELOG entry: null
Related issues
Fixes: https://consensyssoftware.atlassian.net/browse/WPC-441
Manual testing steps
Screenshots/Recordings
Before
After
Pre-merge author checklist
Pre-merge reviewer checklist
Note
Low Risk
Low risk: changes are limited to analytics payload enrichment and dependency upgrades, with updated unit tests to validate new properties.
Overview
Enhances
RPC Service DegradedSegment telemetry by propagating new fields fromNetworkController:rpcEndpointDegradedinto analytics events:rpc_method_name, degradedtype, and (when applicable)retry_reason.Updates
onRpcEndpointDegraded/trackRpcEndpointEventto accept these typed inputs (from@metamask/network-controller) and conditionally include them in tracked properties, with corresponding unit test updates. Also bumps@metamask/network-controllerto^30.0.0(and lockfile deps) to consume the new event payload.Written by Cursor Bugbot for commit a7aacf1. This will update automatically on new commits. Configure here.