feat: add endpoint URL logging for RPC errors #1449
Draft
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Problem
When RPC endpoints become unavailable (due to rate limits, connection issues, etc.), the error logs don't explicitly indicate which endpoint is affected. This makes troubleshooting difficult, especially in multi-chain deployments where operators need to quickly identify which specific endpoint is having issues.
Example of the current error log:
While the chain_id is logged, the actual RPC endpoint URL is missing, requiring operators to cross-reference configuration files to determine which endpoint needs attention.
Solution
This PR adds endpoint URL logging to all RPC error scenarios by:
Storing the endpoint URL in the
Chainstruct - Added anendpointfield and getter method so the URL is accessible throughout the codebaseEnhanced transport layer tracing - Modified
TraceLayerandTraceTransportto includerpc.endpointin OpenTelemetry span attributes, ensuring all RPC calls now include endpoint information in their tracesExplicit health check logging - Updated the health check error logging to include the endpoint URL alongside chain_id
Impact
After these changes, when an RPC endpoint becomes unavailable, logs will clearly show:
This enables operators to:
Testing
Fixes #issue_number
Warning
Firewall rules blocked me from connecting to one or more addresses (expand for details)
I tried to connect to the following addresses, but was blocked by firewall rules:
arb1.arbitrum.io/home/REDACTED/work/relay/relay/target/debug/deps/relay-0116f8e29f20dbc0(dns block)eu-central-mainnet.rpc.ithaca.xyz/home/REDACTED/work/relay/relay/target/debug/deps/relay-0116f8e29f20dbc0(dns block)mainnet.optimism.ioIf you need me to access, download, or install something from one of these locations, you can either:
Original prompt
💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.