Skip to main content

Overview

Lasso tracks RPC performance metrics passively by recording every request’s latency and result. These metrics power intelligent routing decisions, provider leaderboards, and cluster-wide dashboards.

BenchmarkStore

BenchmarkStore is a GenServer that maintains per-chain ETS tables tracking RPC call performance. Storage model:
  • RPC table (bag): Raw call data with dual timestamps (monotonic + system)
  • Score table (set): Aggregated metrics per {provider_id, method, :rpc} key

Recording RPC Calls

Every RPC request records its performance:
Result categories:
  • :success - Request completed successfully
  • :error - RPC error response
  • :timeout - Request timeout
  • :network_error - Connection failure
  • :rate_limit - Rate limit error

Dual Timestamp Design

All metrics use both monotonic and system timestamps:
Benefits:
  • Monotonic time: Accurate intervals immune to clock adjustments
  • System time: Wall-clock correlation for display and exports

ETS Table Structure

RPC metrics table (:rpc_metrics_{profile}_{chain}):
Provider scores table (:provider_scores_{profile}_{chain}):
Example entry:

Score Calculation

Provider scores combine success rate, latency, and call volume:
Formula breakdown:
  • success_rate: 0.0 to 1.0 (e.g., 0.99 = 99% success)
  • latency_factor: 1000 / (1000 + latency), favors lower latency
  • confidence_factor: log10(calls), reduces variance from low-volume providers
Example scores:

Provider Leaderboard

Get provider rankings sorted by performance:

Percentile Calculation

Latency percentiles computed from recent_latencies (last 100 samples):

Method-Specific Performance

Get performance metrics for a specific RPC method:

Bulk Method Performance

Get all method performance data for a chain:

Cluster Aggregation

In clustered deployments, MetricsStore aggregates metrics from all nodes.

Weighted Averages

Metrics are weighted by call volume to prevent skew:
Example:

Per-Node Breakdown

Cluster metrics include per-node latency comparison:

Minimum Call Threshold

Providers need ≥10 calls to be included in aggregated metrics:
Benefits:
  • Prevents skew from nodes that just started
  • Ensures statistical significance
  • Cold-start indicator when threshold not met

Telemetry Metrics

Lasso emits telemetry events for all operational metrics.

Metric Definitions

Defined in Lasso.Telemetry.metrics/0 for LiveDashboard:

Event Emission

Events emitted at key points in request lifecycle:

Custom Telemetry Handlers

Attach custom handlers to route metrics to external systems:

Data Retention

Automatic Cleanup

BenchmarkStore cleans up old data periodically:
Cleanup triggers:
  • Periodic: Every hour (for all chains)
  • Size-based: When table exceeds @max_entries_per_chain

Manual Cleanup

Trigger cleanup manually:

Persistence (Optional)

Hourly snapshots can be saved for long-term analysis:

Performance Characteristics

Memory Usage

Per-entry overhead: ~1KB (compressed ETS)

Query Performance

Summary

Lasso’s metrics system provides:
  • Passive benchmarking via BenchmarkStore (no active probing)
  • Method-specific metrics with percentiles (p50, p90, p95, p99)
  • Provider leaderboards sorted by composite score
  • Cluster aggregation with weighted averages and per-node breakdown
  • Telemetry integration for custom monitoring
  • Automatic cleanup with configurable retention (24 hours default)
  • Low overhead (<1ms per request, <1KB per entry)