pub struct AttemptUsage { /* private fields */ }Expand description
Usage accounted for a single transaction attempt.
Counters are incremented by Transaction as
operations are issued (writes) or resolved (reads). They are always on: no
instrumentation is required to get them.
A new instance is created for every attempt, see the module documentation.
The application metrics recorded with
Transaction::set_custom_metric are
stored here too, and are therefore per-attempt as well. Their map is
allocated on first use, so a transaction that never records one pays
nothing. Without a metrics consumer collecting them (typically
Database::instrumented_run), they are
simply dropped with the generation.
Implementations§
Source§impl AttemptUsage
impl AttemptUsage
Sourcepub fn elapsed(&self) -> Duration
pub fn elapsed(&self) -> Duration
Time elapsed since the attempt started, measured with the clock the attempt was stamped with.
A clock that goes backwards yields zero rather than panicking.
Sourcepub fn bytes_read(&self) -> u64
pub fn bytes_read(&self) -> u64
Bytes read so far, keys and values summed.
Sourcepub fn bytes_written(&self) -> u64
pub fn bytes_written(&self) -> u64
Bytes written so far, keys, values and mutation parameters summed.
Sourcepub fn snapshot(&self) -> UsageSnapshot
pub fn snapshot(&self) -> UsageSnapshot
Takes a consistent-enough copy of every counter.
Counters are read one after the other without a lock, so a snapshot taken while operations are completing may mix values from slightly different instants.
Sourcepub fn custom_metrics(&self) -> HashMap<MetricKey, u64>
pub fn custom_metrics(&self) -> HashMap<MetricKey, u64>
The application metrics recorded during this attempt.