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>
impl<'a> MetricBuilder<'a>
Sourcepub fn new(metrics: &'a ExecutionPlanMetricsSet) -> Self
pub fn new(metrics: &'a ExecutionPlanMetricsSet) -> Self
Create a new MetricBuilder
that will register the result of build()
with the metrics
Sourcepub fn with_label(self, label: Label) -> Self
pub fn with_label(self, label: Label) -> Self
Add a label to the metric being constructed
Sourcepub fn with_new_label(
self,
name: impl Into<Cow<'static, str>>,
value: impl Into<Cow<'static, str>>,
) -> Self
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
Sourcepub fn with_partition(self, partition: usize) -> Self
pub fn with_partition(self, partition: usize) -> Self
Set the partition of the metric being constructed
Sourcepub fn build(self, value: MetricValue)
pub fn build(self, value: MetricValue)
Consume self and create a metric of the specified value registered with the MetricsSet
Sourcepub fn output_rows(self, partition: usize) -> Count
pub fn output_rows(self, partition: usize) -> Count
Consume self and create a new counter for recording output rows
Sourcepub fn spill_count(self, partition: usize) -> Count
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
Sourcepub fn spilled_bytes(self, partition: usize) -> Count
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
Sourcepub fn spilled_rows(self, partition: usize) -> Count
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
Sourcepub fn mem_used(self, partition: usize) -> Gauge
pub fn mem_used(self, partition: usize) -> Gauge
Consume self and create a new gauge for reporting current memory usage
Sourcepub fn counter(
self,
counter_name: impl Into<Cow<'static, str>>,
partition: usize,
) -> Count
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.
Sourcepub fn gauge(
self,
gauge_name: impl Into<Cow<'static, str>>,
partition: usize,
) -> Gauge
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.
Sourcepub fn global_counter(self, counter_name: impl Into<Cow<'static, str>>) -> Count
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)
Sourcepub fn global_gauge(self, gauge_name: impl Into<Cow<'static, str>>) -> Gauge
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)
Sourcepub fn elapsed_compute(self, partition: usize) -> Time
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
Sourcepub fn subset_time(
self,
subset_name: impl Into<Cow<'static, str>>,
partition: usize,
) -> Time
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.
Sourcepub fn start_timestamp(self, partition: usize) -> Timestamp
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
Sourcepub fn end_timestamp(self, partition: usize) -> Timestamp
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> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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