The solanaRpcLatencyWatcher function monitors the latency between Portal and external RPC providers, helping you track indexing performance.
Import
Signature
Parameters
Return Value
Returns a query-transformer combo that already includes the block query it needs. Pass it directly as the source’s outputs. You can chain .pipe() transforms to it.
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 via the built-in metrics registry. See the Data freshness monitoring guide for the full example:
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