Metrics
mercury-metrics provides latency histograms, PnL tracking, and a Prometheus export endpoint.
LatencyTracker
Uses HDR histograms (via hdrhistogram) to record latency with microsecond precision across several orders of magnitude.
Key measurements:
- Feed-to-strategy: time from
BookUpdatepublish toon_bookreturn - Signal-to-submit: time from
Signalpublish tosubmit_ordercall - Submit-to-fill: exchange round-trip time
Access percentiles:
#![allow(unused)]
fn main() {
let p99 = tracker.percentile(99.0); // nanoseconds
let p999 = tracker.percentile(99.9);
}
PnlTracker
Tracks realized and unrealized PnL per symbol:
#![allow(unused)]
fn main() {
tracker.on_fill(&fill);
let pnl = tracker.unrealized_pnl(&symbol, current_mid_price);
}
Prometheus
Metrics are exported on 0.0.0.0:9090/metrics when --metrics is passed. Compatible with any Prometheus scrape target.
Available metrics:
mercury_fill_latency_ns— histogrammercury_pnl_realized_usd— gauge per symbolmercury_orders_submitted_total— countermercury_orders_cancelled_total— countermercury_risk_rejections_total— counter