Skip to content

feat(cli): add --hold-secs to replay so Grafana sees the demo (closes #422)#423

Merged
obchain merged 3 commits intomainfrom
fix/422-replay-hold-secs
May 3, 2026
Merged

feat(cli): add --hold-secs to replay so Grafana sees the demo (closes #422)#423
obchain merged 3 commits intomainfrom
fix/422-replay-hold-secs

Conversation

@obchain
Copy link
Copy Markdown
Owner

@obchain obchain commented May 3, 2026

Summary

`replay` exits in well under one Prometheus scrape interval, so the Grafana dashboard never sees any replay data — Queue depth, Profit predicted, Executor simulations/min all show "No data" / zeros even when the bot identifies $39k+ of liquidatable opportunities.

Fix

  • Add `--hold-secs ` flag (default `0`, current CI-friendly behaviour). After the one-shot pipeline emits, sleep N seconds with `/metrics` still serving so at least one scrape lands.
  • Start the metrics exporter at the top of the replay path. Previously only `listen` installed it, so the held-open window would have served nothing.

Test plan

  • `cargo check` clean.
  • Local validation against block 91323624 with `--hold-secs 25`:
    • `charon_executor_profit_usd_cents_sum{chain="bnb"} 3952448` (matches the 4 JSON records' `predicted_net_profit_usd_cents` sum, \$39,524.48).
    • `charon_executor_queue_depth 4`.
    • `charon_scanner_positions{bucket="liquidatable"} 4`.
  • `--hold-secs 0` (default) keeps current CI / smoke-test behaviour.

Cosmetic UX, no risk to production paths.

obchain added 3 commits May 3, 2026 22:52
…422)

`replay` exits in well under one Prometheus scrape interval, so the
Grafana dashboard never sees any replay data — Queue depth, Profit
predicted, Executor simulations/min all show "No data" or zeros even
when the bot identified $39k+ of liquidatable opportunities.

Add a `--hold-secs <N>` flag (default 0, current behaviour) that
keeps the metrics exporter open for N seconds after the one-shot
pipeline emits. Also start the metrics exporter at the top of the
replay path so the held-open window actually serves `/metrics` —
previously only the `listen` path installed the exporter.

Local validation against block 91323624:

  curl http://127.0.0.1:9091/metrics | grep profit_usd_cents_sum
  charon_executor_profit_usd_cents_sum{chain="bnb"} 3952448

Matches the four JSON records' `predicted_net_profit_usd_cents` sum
(\$39,524.48). Default-zero hold preserves CI / smoke-test behaviour.
…ow-up)

The Profit (predicted/realised) stat panels used
`sum(increase(...)[$__range])) / 100` which only fires when Prometheus
sees a 0->bump transition. `replay` bumps the counter once in <1s,
well below Prometheus's 15s scrape interval, so the panel always
showed 0 even when the bot identified $39k+ of opportunities.

Switch the two profit-stat panels to the gauge form
`sum(charon_executor_*_profit_usd_cents_sum) / 100` so the dashboard
shows the cumulative total since the bot started. For replay this is
the replay's emitted profit; for production listen runs it is the
running total since the latest bot start, which is the more useful
number anyway (operators read realised profit per range from the
heatmap below). Legend updated to 'cumulative' to match the new
semantic. Bumped dashboard version so provisioning re-imports.

Pairs with #422's --hold-secs flag — together they let the dashboard
serve a useful demo number against any pinned-block fork run.
@obchain obchain merged commit 65a2839 into main May 3, 2026
5 checks passed
@obchain obchain deleted the fix/422-replay-hold-secs branch May 3, 2026 17:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant