The evmRpcLatencyWatcher subscribes to RPC endpoints via WebSocket and measures when blocks arrive at the Portal versus when they appear at the RPC endpoints.
The measured values include client-side network latency. For RPC endpoints, only the arrival time of blocks is measured. This does not capture the node’s internal processing or response latency if queried directly. Results represent end-to-end delays as experienced by the client, not pure Portal or RPC processing performance.
Pass the watcher as the source output. You can chain a .pipe() transform to it, for example to expose the measurements as Prometheus metrics:
Data freshness data includes:
number / timestamp: the observed block and its timestamp
portal.receivedAt: when the block arrived from the Portal
rpc: one entry per configured RPC endpoint:
url: RPC endpoint URL
receivedAt: when the RPC endpoint received the block
hash: block hash as seen by the RPC
portalDelayMs: milliseconds between RPC arrival and Portal availability
The Prometheus gauge registered in the .pipe() transform above is served on the metricsServer() port, http://localhost:9090/metrics in this example. See the Metrics guide for details on custom metrics.