Skip to content

Commit ed4ea0e

Browse files
authored
Add output format and table format labels to filesystem sink trace events (ArroyoSystems#1019)
1 parent ec12e8b commit ed4ea0e

4 files changed

Lines changed: 32 additions & 12 deletions

File tree

crates/arroyo-connectors/src/filesystem/mod.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,14 @@ pub enum TableFormat {
4040
}
4141

4242
impl TableFormat {
43+
pub fn name(&self) -> &'static str {
44+
match self {
45+
TableFormat::None => "none",
46+
TableFormat::Delta => "delta",
47+
TableFormat::Iceberg(_) => "iceberg",
48+
}
49+
}
50+
4351
pub async fn get_storage_provider(
4452
&mut self,
4553
task_info: Arc<TaskInfo>,

crates/arroyo-connectors/src/filesystem/sink/mod.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,8 @@ impl<R: BatchBufferingWriter + Send + 'static> FileSystemSink<R> {
8080
partitioner_mode: PartitionerMode,
8181
connection_id: Option<String>,
8282
) -> TwoPhaseCommitterOperator<Self> {
83+
let output_format = format.name();
84+
let table_format_name = table_format.name();
8385
TwoPhaseCommitterOperator::new(Self {
8486
sender: None,
8587
checkpoint_receiver: None,
@@ -95,6 +97,8 @@ impl<R: BatchBufferingWriter + Send + 'static> FileSystemSink<R> {
9597
event_logger: FsEventLogger {
9698
task_info: None,
9799
connection_id: connection_id.unwrap_or_default().into(),
100+
output_format,
101+
table_format: table_format_name,
98102
},
99103
_ts: Default::default(),
100104
})
@@ -186,6 +190,8 @@ fn map_object_store_error(obj_err: &object_store::Error) -> DataflowError {
186190
pub struct FsEventLogger {
187191
task_info: Option<Arc<TaskInfo>>,
188192
connection_id: Arc<String>,
193+
output_format: &'static str,
194+
table_format: &'static str,
189195
}
190196

191197
impl FsEventLogger {
@@ -209,6 +215,8 @@ impl FsEventLogger {
209215
"connection_id": self.connection_id.as_str(),
210216
"write_error_reason": failure_message.as_deref().unwrap_or(""),
211217
"subtask_idx": task_info.task_index,
218+
"output_format": self.output_format,
219+
"table_format": self.table_format,
212220
}, [
213221
"bytes_written" => bytes as f64,
214222
"files_written" => files as f64,

crates/arroyo-connectors/src/filesystem/sink/v2/mod.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -304,6 +304,8 @@ impl<BBW: BatchBufferingWriter + Send + 'static> FileSystemSinkV2<BBW> {
304304
}
305305

306306
let connection_id_str = connection_id.clone().unwrap_or_default();
307+
let output_format = format.name();
308+
let table_format_name = table_format.name();
307309

308310
Self {
309311
config: SinkConfig {
@@ -328,6 +330,8 @@ impl<BBW: BatchBufferingWriter + Send + 'static> FileSystemSinkV2<BBW> {
328330
event_logger: FsEventLogger {
329331
task_info: None,
330332
connection_id: connection_id_str.into(),
333+
output_format,
334+
table_format: table_format_name,
331335
},
332336
watermark: None,
333337
}

crates/arroyo-rpc/src/formats.rs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -376,22 +376,22 @@ pub enum Format {
376376

377377
impl Display for Format {
378378
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
379-
write!(
380-
f,
381-
"{}",
382-
match self {
383-
Format::Json(_) => "json",
384-
Format::Avro(_) => "avro",
385-
Format::Protobuf(_) => "protobuf",
386-
Format::Parquet(_) => "parquet",
387-
Format::RawString(_) => "raw_string",
388-
Format::RawBytes(_) => "raw_bytes",
389-
}
390-
)
379+
f.write_str(self.name())
391380
}
392381
}
393382

394383
impl Format {
384+
pub fn name(&self) -> &'static str {
385+
match self {
386+
Format::Json(_) => "json",
387+
Format::Avro(_) => "avro",
388+
Format::Protobuf(_) => "protobuf",
389+
Format::Parquet(_) => "parquet",
390+
Format::RawString(_) => "raw_string",
391+
Format::RawBytes(_) => "raw_bytes",
392+
}
393+
}
394+
395395
pub fn from_opts(opts: &mut ConnectorOptions) -> DFResult<Option<Self>> {
396396
let Some(name) = opts.pull_opt_str("format")? else {
397397
return Ok(None);

0 commit comments

Comments
 (0)