Expand description
Benchmark timing injection for YAML-loaded routes.
When BENCH_LATENCY_FILE env var is set, every top-level BuilderStep::To(_)
in each route definition is wrapped with two processors:
- Pre: stores
Arc<Instant::now()>inexchange.extensions["BenchStart"] - Post: reads it back, computes
elapsed().as_nanos(), writesBENCH_LATENCY <id> <duration_ns>to the shared file.
Per-pair Arc<AtomicU64> counter guarantees coherent ids. The latency
file is opened once at injection time and shared via Arc<Mutex<File>>
(no per-tick reopen). When the env var is unset, this module is a no-op.
Only top-level To steps are wrapped — nested steps inside Choice,
Split, Filter etc. are left untouched (wrapping those would measure
per-sub-message latency, not per-tick bridge tax).
Functions§
- maybe_
instrument_ routes - If
BENCH_LATENCY_FILEis set, instrument each route by wrapping top-levelTosteps with timing processors. Returns defs unchanged when the env var is absent (zero-cost no-op).