DerGut commented on code in PR #1496: URL: https://github.com/apache/iceberg-rust/pull/1496#discussion_r2200246689
########## crates/iceberg/src/metrics.rs: ########## @@ -0,0 +1,154 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +//! This module contains the metrics reporting API for Iceberg. +//! +//! It is used to report table operations in a pluggable way. See the [docs] +//! for more details. +//! +//! [docs] https://iceberg.apache.org/docs/latest/metrics-reporting + +use std::collections::HashMap; +use std::fmt::Debug; +use std::sync::Arc; +use std::time::Duration; + +use async_trait::async_trait; +use tracing::info; + +use crate::TableIdent; +use crate::expr::Predicate; +use crate::spec::SchemaId; + +/// This trait defines the API for reporting metrics of table operations. +/// +/// Refer to the [Iceberg docs] for details. +/// +/// [Iceberg docs]: https://iceberg.apache.org/docs/latest/metrics-reporting/ +#[async_trait] +pub(crate) trait MetricsReporter: Debug + Send + Sync { + /// Indicates that an operation is done by reporting a MetricsReport. + /// + /// Any errors are expected to be handled internally. + async fn report(&self, report: MetricsReport); +} + +/// An enum of all metrics reports. +#[derive(Debug)] +pub(crate) enum MetricsReport { + /// A Table Scan report that contains all relevant information from a Table Scan. + Scan { + table: TableIdent, + snapshot_id: i64, + schema_id: SchemaId, + + /// If None, the scan is an unfiltered full table scan. + filter: Option<Arc<Predicate>>, + + /// If None, the scan projects all fields. + // TODO: We could default to listing all field names in those cases: check what Java is doing. + projected_field_names: Option<Vec<String>>, Review Comment: Done with https://github.com/apache/iceberg-rust/pull/1496/commits/a2007d85b00a087337268d9b9acda715b09e2e01 -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: issues-unsubscr...@iceberg.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: issues-unsubscr...@iceberg.apache.org For additional commands, e-mail: issues-h...@iceberg.apache.org