pub struct Metric {
value: MetricValue,
labels: Vec<Label>,
partition: Option<usize>,
metric_type: MetricType,
}Expand description
Something that tracks a value of interest (metric) of a DataFusion
ExecutionPlan execution.
Typically Metrics are not created directly, but instead
are created using MetricBuilder or methods on
ExecutionPlanMetricsSet.
use datafusion_physical_plan::metrics::*;
let metrics = ExecutionPlanMetricsSet::new();
assert!(metrics.clone_inner().output_rows().is_none());
// Create a counter to increment using the MetricBuilder
let partition = 1;
let output_rows = MetricBuilder::new(&metrics).output_rows(partition);
// Counter can be incremented
output_rows.add(13);
// The value can be retrieved directly:
assert_eq!(output_rows.value(), 13);
// As well as from the metrics set
assert_eq!(metrics.clone_inner().output_rows(), Some(13));Fields§
§value: MetricValueThe value of the metric
labels: Vec<Label>arbitrary name=value pairs identifying this metric
partition: Option<usize>To which partition of an operators output did this metric
apply? If None then means all partitions.
metric_type: MetricTypeImplementations§
Source§impl Metric
impl Metric
Sourcepub fn new(value: MetricValue, partition: Option<usize>) -> Self
pub fn new(value: MetricValue, partition: Option<usize>) -> Self
Create a new Metric. Consider using MetricBuilder
rather than this function directly.
Sourcepub fn new_with_labels(
value: MetricValue,
partition: Option<usize>,
labels: Vec<Label>,
) -> Self
pub fn new_with_labels( value: MetricValue, partition: Option<usize>, labels: Vec<Label>, ) -> Self
Create a new Metric. Consider using MetricBuilder
rather than this function directly.
Sourcepub fn with_type(self, metric_type: MetricType) -> Self
pub fn with_type(self, metric_type: MetricType) -> Self
Set the type for this metric. Defaults to MetricType::DEV
Sourcepub fn with_label(self, label: Label) -> Self
pub fn with_label(self, label: Label) -> Self
Add a new label to this metric
Sourcepub fn value(&self) -> &MetricValue
pub fn value(&self) -> &MetricValue
Return a reference to the value of this metric
Sourcepub fn value_mut(&mut self) -> &mut MetricValue
pub fn value_mut(&mut self) -> &mut MetricValue
Return a mutable reference to the value of this metric
Sourcepub fn metric_type(&self) -> MetricType
pub fn metric_type(&self) -> MetricType
Return the metric type (verbosity level) associated with this metric
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Metric
impl !RefUnwindSafe for Metric
impl Send for Metric
impl Sync for Metric
impl Unpin for Metric
impl !UnwindSafe for Metric
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
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
§impl<T> ToStringFallible for Twhere
T: Display,
impl<T> ToStringFallible for Twhere
T: Display,
§fn try_to_string(&self) -> Result<String, TryReserveError>
fn try_to_string(&self) -> Result<String, TryReserveError>
ToString::to_string, but without panic on OOM.