use datafusion_physical_plan::metrics::{
Count, ExecutionPlanMetricsSet, Gauge, MetricBuilder, MetricType, PruningMetrics,
RatioMergeStrategy, RatioMetrics, Time,
};
#[derive(Debug, Clone)]
pub struct ParquetFileMetrics {
pub files_ranges_pruned_statistics: PruningMetrics,
pub predicate_evaluation_errors: Count,
pub row_groups_pruned_bloom_filter: PruningMetrics,
pub limit_pruned_row_groups: PruningMetrics,
pub row_groups_pruned_statistics: PruningMetrics,
pub bytes_scanned: Count,
pub pushdown_rows_pruned: Count,
pub pushdown_rows_matched: Count,
pub row_pushdown_eval_time: Time,
pub statistics_eval_time: Time,
pub bloom_filter_eval_time: Time,
pub page_index_rows_pruned: PruningMetrics,
pub page_index_pages_pruned: PruningMetrics,
pub page_index_eval_time: Time,
pub metadata_load_time: Time,
pub scan_efficiency_ratio: RatioMetrics,
pub predicate_cache_inner_records: Gauge,
pub predicate_cache_records: Gauge,
}
impl ParquetFileMetrics {
pub fn new(
partition: usize,
filename: &str,
metrics: &ExecutionPlanMetricsSet,
) -> Self {
let row_groups_pruned_bloom_filter = MetricBuilder::new(metrics)
.with_new_label("filename", filename.to_string())
.with_type(MetricType::SUMMARY)
.pruning_metrics("row_groups_pruned_bloom_filter", partition);
let limit_pruned_row_groups = MetricBuilder::new(metrics)
.with_new_label("filename", filename.to_string())
.with_type(MetricType::SUMMARY)
.pruning_metrics("limit_pruned_row_groups", partition);
let row_groups_pruned_statistics = MetricBuilder::new(metrics)
.with_new_label("filename", filename.to_string())
.with_type(MetricType::SUMMARY)
.pruning_metrics("row_groups_pruned_statistics", partition);
let page_index_pages_pruned = MetricBuilder::new(metrics)
.with_new_label("filename", filename.to_string())
.with_type(MetricType::SUMMARY)
.pruning_metrics("page_index_pages_pruned", partition);
let bytes_scanned = MetricBuilder::new(metrics)
.with_new_label("filename", filename.to_string())
.with_type(MetricType::SUMMARY)
.counter("bytes_scanned", partition);
let metadata_load_time = MetricBuilder::new(metrics)
.with_new_label("filename", filename.to_string())
.with_type(MetricType::SUMMARY)
.subset_time("metadata_load_time", partition);
let files_ranges_pruned_statistics = MetricBuilder::new(metrics)
.with_type(MetricType::SUMMARY)
.pruning_metrics("files_ranges_pruned_statistics", partition);
let scan_efficiency_ratio = MetricBuilder::new(metrics)
.with_new_label("filename", filename.to_string())
.with_type(MetricType::SUMMARY)
.ratio_metrics_with_strategy(
"scan_efficiency_ratio",
partition,
RatioMergeStrategy::AddPartSetTotal,
);
let predicate_evaluation_errors = MetricBuilder::new(metrics)
.with_new_label("filename", filename.to_string())
.counter("predicate_evaluation_errors", partition);
let pushdown_rows_pruned = MetricBuilder::new(metrics)
.with_new_label("filename", filename.to_string())
.counter("pushdown_rows_pruned", partition);
let pushdown_rows_matched = MetricBuilder::new(metrics)
.with_new_label("filename", filename.to_string())
.counter("pushdown_rows_matched", partition);
let row_pushdown_eval_time = MetricBuilder::new(metrics)
.with_new_label("filename", filename.to_string())
.subset_time("row_pushdown_eval_time", partition);
let statistics_eval_time = MetricBuilder::new(metrics)
.with_new_label("filename", filename.to_string())
.subset_time("statistics_eval_time", partition);
let bloom_filter_eval_time = MetricBuilder::new(metrics)
.with_new_label("filename", filename.to_string())
.subset_time("bloom_filter_eval_time", partition);
let page_index_eval_time = MetricBuilder::new(metrics)
.with_new_label("filename", filename.to_string())
.subset_time("page_index_eval_time", partition);
let page_index_rows_pruned = MetricBuilder::new(metrics)
.with_new_label("filename", filename.to_string())
.pruning_metrics("page_index_rows_pruned", partition);
let predicate_cache_inner_records = MetricBuilder::new(metrics)
.with_new_label("filename", filename.to_string())
.gauge("predicate_cache_inner_records", partition);
let predicate_cache_records = MetricBuilder::new(metrics)
.with_new_label("filename", filename.to_string())
.gauge("predicate_cache_records", partition);
Self {
files_ranges_pruned_statistics,
predicate_evaluation_errors,
row_groups_pruned_bloom_filter,
row_groups_pruned_statistics,
limit_pruned_row_groups,
bytes_scanned,
pushdown_rows_pruned,
pushdown_rows_matched,
row_pushdown_eval_time,
page_index_rows_pruned,
page_index_pages_pruned,
statistics_eval_time,
bloom_filter_eval_time,
page_index_eval_time,
metadata_load_time,
scan_efficiency_ratio,
predicate_cache_inner_records,
predicate_cache_records,
}
}
}