Crate bus_contract_timings
Expand description
§bus-contract-timings
The timings contract of bus-contract: how long listeners take, per point and per listener, and the passes over a point’s budget.
bus-contract is a small core (points, order, alter and collect,
requests, local listeners, introspection) plus optional capabilities.
Each capability is its own contract, published as its own crate and
versioned on its own, so a change to one does not break the users of
the others.
§Use
use std::sync::Arc;
use bus_contract_timings::BusTimings;
/// Whether the bus offers the timings capability.
fn has_timings(bus: &Arc<dyn bus_contract::Bus>) -> bool {
bus.timings().is_some()
}BusTimingsgivesbus.timings()on any bus:dyn Bus,Arc<dyn Bus>or a concrete one. It returnsNonewhen the bus does not offer the capability.- The contract’s items live here:
Timings,TimingStats,PointTimings,ListenerTimings,OverBudget,BudgetSink,OVER_BUDGET_FACT, and theCONTRACT.
§Status: owns its contract since 0.2
Since 0.2, with bus-contract 0.5, the items above are defined here,
not in the core. The core names no capability: it keeps the typed
lookup (Bus::capability), the Contract and Facet types, and
offers. BusTimings reaches the capability through that lookup only.
Upgrading from 0.1 and bus-contract 0.4: import the items from
bus_contract_timings and add use bus_contract_timings::BusTimings; where
bus.timings() is called. Every rename is in
MIGRATION-0.5.md.
§Guarantees
What a bus offering this capability guarantees, and what it does not,
property by property with stable ids, is the
timings section of GUARANTEES.md. Each property names the
bus-kernel conformance check
that proves it.
§Versions
Released on its own, with its own CHANGELOG. Needs
bus-contract 1. See
RELEASING.md
for the repository’s crates and their publish order.
§License
MIT or Apache-2.0, at your option.
Structs§
- Listener
Timings - One listener’s time on a point (
PointTimings::listeners). - Over
Budget - A pass of a point’s listeners that went over its budget
(
PointSpec::budget): reported to the budget sinks (Timings::add_budget_sink). The pass’s results were kept: a budget is not a deadline. - Point
Timings - A point’s time (
Timings::points): its passes, its listeners, its budget and how often a pass went over. - Timing
Stats - How long something took over a window of runs
(
Timings): a listener’s runs, or a point’s passes. The quantiles may be approximate (an implementation may read them from a histogram); the count, total and max are exact.
Constants§
- CONTRACT
- The timings contract: a bus offers it by answering for
dyn TimingsinBus::capability. A point’s budget (PointSpec::budget) needs no contract: on a bus without this one it is only shown. - OVER_
BUDGET_ FACT - The name a host gives the fact it publishes for each
OverBudgetits budget sinks receive (Timings::add_budget_sink).
Traits§
- BusTimings
- Reaches the
Timingscapability of any bus:bus.timings(). - Timings
- A capability of a bus (
BusTimings::timings): how long listeners take, per point and per listener, and the passes over a point’s budget (PointSpec::budget) reported as they happen.
Type Aliases§
- Budget
Sink - Receives each pass over a point’s budget (
OverBudget).