foundationdb::budget

Struct AttemptUsage

Source
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

Source

pub fn new() -> Self

Starts a new, empty accounting generation, measured with the WallClock.

Source

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.

Source

pub fn bytes_read(&self) -> u64

Bytes read so far, keys and values summed.

Source

pub fn bytes_written(&self) -> u64

Bytes written so far, keys, values and mutation parameters summed.

Source

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.

Source

pub fn custom_metrics(&self) -> HashMap<MetricKey, u64>

The application metrics recorded during this attempt.

Trait Implementations§

Source§

impl Debug for AttemptUsage

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for AttemptUsage

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.