Bastion.Telemetry.Aggregator
lib/telemetry_aggregator.march — Bastion.Telemetry.Aggregator
A Vault-backed ring buffer that collects all telemetry events per request and provides a waterfall view. Attaches to the ["bastion"] event prefix so it receives every framework event automatically.
── Usage ──────────────────────────────────────────────────────────────────────
-- At application startup:
Bastion.Telemetry.Aggregator.start(100)
-- In a dashboard handler:
let requests = Bastion.Telemetry.Aggregator.recent_requests(20)
let waterfall = Bastion.Telemetry.Aggregator.request_waterfall(request_id)
let stats = Bastion.Telemetry.Aggregator.counters()Types
Functions
Compute aggregate counters from the ring buffer.
Returns a record with:
total — total number of requests in the buffer
errors — count of requests with error: true
avg_duration_ms — mean duration across all buffered requests
let c = Bastion.Telemetry.Aggregator.counters()
c.total -- Int
c.errors -- Int
c.avg_duration_ms -- IntReturn the most recent limit RequestSummaries from the ring buffer, newest first.
let requests = Bastion.Telemetry.Aggregator.recent_requests(20)Look up all events recorded for a specific request and build a WaterfallData.
Returns `Some(WaterfallData)` if the request_id is known, `None` otherwise.
match Bastion.Telemetry.Aggregator.request_waterfall(id) do
Some(w) -> render_waterfall(w)
None -> send_404(conn)
endClear all aggregator state — both event and request tables.
Start the aggregator. Attaches a telemetry handler to all bastion events and initialises the Vault storage tables.
max_requests — how many RequestSummary entries to retain in the ring buffer.
Pass 0 to use the default (100).
Bastion.Telemetry.Aggregator.start(100)