Struct datafusion_physical_plan::metrics::MetricBuilder

source ·
pub struct MetricBuilder<'a> { /* private fields */ }
Expand description

Structure for constructing metrics, counters, timers, etc.

Note the use of Cow<..> is to avoid allocations in the common case of constant strings

 use datafusion_physical_plan::metrics::*;

 let metrics = ExecutionPlanMetricsSet::new();
 let partition = 1;

 // Create the standard output_rows metric
 let output_rows = MetricBuilder::new(&metrics).output_rows(partition);

 // Create a operator specific counter with some labels
 let num_bytes = MetricBuilder::new(&metrics)
   .with_new_label("filename", "my_awesome_file.parquet")
   .counter("num_bytes", partition);

Implementations§

source§

impl<'a> MetricBuilder<'a>

source

pub fn new(metrics: &'a ExecutionPlanMetricsSet) -> Self

Create a new MetricBuilder that will register the result of build() with the metrics

source

pub fn with_label(self, label: Label) -> Self

Add a label to the metric being constructed

source

pub fn with_new_label( self, name: impl Into<Cow<'static, str>>, value: impl Into<Cow<'static, str>>, ) -> Self

Add a label to the metric being constructed

source

pub fn with_partition(self, partition: usize) -> Self

Set the partition of the metric being constructed

source

pub fn build(self, value: MetricValue)

Consume self and create a metric of the specified value registered with the MetricsSet

source

pub fn output_rows(self, partition: usize) -> Count

Consume self and create a new counter for recording output rows

source

pub fn spill_count(self, partition: usize) -> Count

Consume self and create a new counter for recording the number of spills triggered by an operator

source

pub fn spilled_bytes(self, partition: usize) -> Count

Consume self and create a new counter for recording the total spilled bytes triggered by an operator

source

pub fn spilled_rows(self, partition: usize) -> Count

Consume self and create a new counter for recording the total spilled rows triggered by an operator

source

pub fn mem_used(self, partition: usize) -> Gauge

Consume self and create a new gauge for reporting current memory usage

source

pub fn counter( self, counter_name: impl Into<Cow<'static, str>>, partition: usize, ) -> Count

Consumes self and creates a new Count for recording some arbitrary metric of an operator.

source

pub fn gauge( self, gauge_name: impl Into<Cow<'static, str>>, partition: usize, ) -> Gauge

Consumes self and creates a new Gauge for reporting some arbitrary metric of an operator.

source

pub fn global_counter(self, counter_name: impl Into<Cow<'static, str>>) -> Count

Consumes self and creates a new Count for recording a metric of an overall operator (not per partition)

source

pub fn global_gauge(self, gauge_name: impl Into<Cow<'static, str>>) -> Gauge

Consumes self and creates a new Gauge for reporting a metric of an overall operator (not per partition)

source

pub fn elapsed_compute(self, partition: usize) -> Time

Consume self and create a new Timer for recording the elapsed CPU time spent by an operator

source

pub fn subset_time( self, subset_name: impl Into<Cow<'static, str>>, partition: usize, ) -> Time

Consumes self and creates a new Timer for recording some subset of an operators execution time.

source

pub fn start_timestamp(self, partition: usize) -> Timestamp

Consumes self and creates a new Timestamp for recording the starting time of execution for a partition

source

pub fn end_timestamp(self, partition: usize) -> Timestamp

Consumes self and creates a new Timestamp for recording the ending time of execution for a partition

Auto Trait Implementations§

§

impl<'a> Freeze for MetricBuilder<'a>

§

impl<'a> !RefUnwindSafe for MetricBuilder<'a>

§

impl<'a> Send for MetricBuilder<'a>

§

impl<'a> Sync for MetricBuilder<'a>

§

impl<'a> Unpin for MetricBuilder<'a>

§

impl<'a> !UnwindSafe for MetricBuilder<'a>

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> IntoEither for T

source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
source§

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

§

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>,

§

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.
source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

source§

fn vzip(self) -> V