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>
impl<'a> MetricBuilder<'a>
sourcepub fn new(metrics: &'a ExecutionPlanMetricsSet) -> MetricBuilder<'a>
pub fn new(metrics: &'a ExecutionPlanMetricsSet) -> MetricBuilder<'a>
Create a new MetricBuilder
that will register the result of build()
with the metrics
sourcepub fn with_label(self, label: Label) -> MetricBuilder<'a>
pub fn with_label(self, label: Label) -> MetricBuilder<'a>
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>>
) -> MetricBuilder<'a>
pub fn with_new_label( self, name: impl Into<Cow<'static, str>>, value: impl Into<Cow<'static, str>> ) -> MetricBuilder<'a>
Add a label to the metric being constructed
sourcepub fn with_partition(self, partition: usize) -> MetricBuilder<'a>
pub fn with_partition(self, partition: usize) -> MetricBuilder<'a>
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 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 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