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 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 batch carries the samples that became decidable in it, so iterate the result:
A sample is emitted once both the Portal and the RPC endpoints have reported the slot, or once the wait window closes. rpc carries one entry per configured endpoint on every sample. portalDelayMs is signed. A negative value means the Portal delivered the slot before that endpoint did. If these values feed a histogram, revisit the buckets and any max(0, ...) clamping, or Portal leads fold back into the zero bucket. portalDelayMs and receivedAt are absent whenever unresolved is set: Count unresolved entries rather than charting them. A missing delay is not zero.

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. Skip the entries that carry unresolved, since they have no delay to record. See the Data freshness monitoring guide for the full example:

How It Works

The RPC latency watcher:
  1. Subscribes to slot updates via WebSocket (slotsUpdatesSubscribe)
  2. Listens for optimisticConfirmation events from each RPC
  3. Holds each slot until both sides have reported it, or until resolveTimeoutMs passes
  4. Reports the signed delay as portalDelayMs, or unresolved when an endpoint never reported the slot
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