Skip to main content
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:
  1. Subscribes to slot updates via WebSocket (slotsUpdatesSubscribe)
  2. Listens for optimisticConfirmation events from each RPC
  3. Compares the arrival time of blocks between RPC and Portal
  4. 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