Skip to content

Commit 7d33b89

Browse files
authored
Merge pull request JanKaul#259 from JanKaul/add-traces
add traces to common functions
2 parents b4f8b91 + 8fc98a8 commit 7d33b89

File tree

6 files changed

+39
-5
lines changed

6 files changed

+39
-5
lines changed

datafusion_iceberg/src/table.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -350,8 +350,8 @@ fn fake_object_store_url(table_location_url: &str) -> ObjectStoreUrl {
350350
}
351351

352352
#[allow(clippy::too_many_arguments)]
353-
#[instrument(level = "debug", skip(arrow_schema, statistics, session, filters), fields(
354-
table_location = %table.metadata().location,
353+
#[instrument(name = "datafusion_iceberg::table_scan", level = "debug", skip(arrow_schema, statistics, session, filters), fields(
354+
table_identifier = %table.identifier(),
355355
snapshot_range = ?snapshot_range,
356356
projection = ?projection,
357357
filter_count = filters.len(),
@@ -1112,6 +1112,10 @@ pub async fn write_parquet_equality_delete_files(
11121112
write_parquet_files(table, batches, context, Some(equality_ids), branch).await
11131113
}
11141114

1115+
#[instrument(name = "datafusion_iceberg::write_parquet_files", level = "debug", skip(table, batches, context), fields(
1116+
table_identifier = %table.identifier(),
1117+
branch = ?branch
1118+
))]
11151119
async fn write_parquet_files(
11161120
table: &Table,
11171121
batches: SendableRecordBatchStream,

iceberg-rust/src/file_format/parquet.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,17 @@ use parquet::{
2323
schema::types::{from_thrift, SchemaDescriptor},
2424
};
2525
use thrift::protocol::{TCompactOutputProtocol, TSerializable};
26+
use tracing::instrument;
2627

2728
use crate::error::Error;
2829

2930
/// Read datafile statistics from parquetfile
31+
#[instrument(name = "iceberg_rust::file_format::parquet::parquet_to_datafile", level = "debug", skip(file_metadata, schema, partition_fields), fields(
32+
location = location,
33+
file_size = file_size,
34+
partition_field_count = partition_fields.len(),
35+
has_equality_ids = equality_ids.is_some()
36+
))]
3037
pub fn parquet_to_datafile(
3138
location: &str,
3239
file_size: u64,

iceberg-rust/src/table/mod.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ use iceberg_rust_spec::{
3434
},
3535
};
3636

37+
use tracing::instrument;
38+
3739
use crate::{
3840
catalog::{create::CreateTableBuilder, identifier::Identifier, Catalog},
3941
error::Error,
@@ -199,6 +201,11 @@ impl Table {
199201
/// Returns an error if:
200202
/// * The end snapshot ID is invalid
201203
/// * Reading the manifest list fails
204+
#[instrument(name = "iceberg_rust::table::manifests", level = "debug", skip(self), fields(
205+
table_identifier = %self.identifier,
206+
start = ?start,
207+
end = ?end
208+
))]
202209
pub async fn manifests(
203210
&self,
204211
start: Option<i64>,
@@ -295,6 +302,11 @@ impl Table {
295302
/// Path of a Manifest file
296303
pub type ManifestPath = String;
297304

305+
#[instrument(name = "iceberg_rust::table::datafiles", level = "debug", skip(object_store, manifests), fields(
306+
manifest_count = manifests.len(),
307+
filter_provided = filter.is_some(),
308+
sequence_range = ?sequence_number_range
309+
))]
298310
async fn datafiles(
299311
object_store: Arc<dyn ObjectStore>,
300312
manifests: &'_ [ManifestListEntry],

iceberg-rust/src/table/transaction/mod.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
//! * Managing snapshots and branches
1717
1818
use std::collections::HashMap;
19-
use tracing::debug;
19+
use tracing::{debug, instrument};
2020

2121
use iceberg_rust_spec::spec::{manifest::DataFile, schema::Schema, snapshot::SnapshotReference};
2222

@@ -419,6 +419,10 @@ impl<'table> TableTransaction<'table> {
419419
/// .commit()
420420
/// .await?;
421421
/// ```
422+
#[instrument(name = "iceberg_rust::table::transaction::commit", level = "debug", skip(self), fields(
423+
table_identifier = %self.table.identifier,
424+
branch = ?self.branch
425+
))]
422426
pub async fn commit(self) -> Result<(), Error> {
423427
let catalog = self.table.catalog();
424428
let identifier = self.table.identifier.clone();

iceberg-rust/src/table/transaction/operation.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,11 @@ pub enum Operation {
110110
}
111111

112112
impl Operation {
113-
#[instrument(level = "debug", skip(object_store))]
113+
#[instrument(
114+
name = "iceberg_rust::table::transaction::operation::execute",
115+
level = "debug",
116+
skip(object_store)
117+
)]
114118
pub async fn execute(
115119
self,
116120
table_metadata: &TableMetadata,

iceberg-rust/src/view/transaction/operation.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,10 @@ fn upsert_representations(
8080

8181
impl Operation {
8282
/// Execute operation
83-
#[instrument(level = "debug")]
83+
#[instrument(
84+
name = "iceberg_rust::view::transaction::operation::execute",
85+
level = "debug"
86+
)]
8487
pub async fn execute<T: Materialization + Debug>(
8588
self,
8689
metadata: &GeneralViewMetadata<T>,

0 commit comments

Comments
 (0)