The solanaRpcLatencyWatcher function monitors the latency between Portal and external RPC providers, helping you track indexing performance.
Import
Signature
Parameters
Return Value
Returns a transformer that can be piped to add latency data to the stream.
Output Data Structure
Each output contains:
Basic Usage
Example Output
Multiple RPC Endpoints
Monitor multiple RPC providers simultaneously:
Metrics Integration
Export latency data to Prometheus or other monitoring systems:
Prometheus Export
Full example with HTTP metrics endpoint:
How It Works
The RPC latency watcher:
- Subscribes to slot updates via WebSocket (
slotsUpdatesSubscribe)
- Listens for
optimisticConfirmation events from each RPC
- Compares the arrival time of blocks between RPC and Portal
- Reports the delay as
portalDelayMs
The measured values include client-side network latency. For RPC, only the arrival time of the block is measured—this does not capture the node’s internal processing latency.
Use Cases
- Performance monitoring - Track indexing latency in production
- RPC comparison - Compare performance across different RPC providers
- Alerting - Trigger alerts when latency exceeds thresholds
- Optimization - Identify bottlenecks in your indexing pipeline