Skip to content

fix: staging files count in metrics #1207

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 25, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 20 additions & 13 deletions src/parseable/streams.rs
Original file line number Diff line number Diff line change
Expand Up @@ -444,21 +444,27 @@ impl Stream {
.set(0);
}

//find sum of arrow files in staging directory for a stream
let total_arrow_files = staging_files.values().map(|v| v.len()).sum::<usize>();
metrics::STAGING_FILES
.with_label_values(&[&self.stream_name])
.set(total_arrow_files as i64);

//find sum of file sizes of all arrow files in staging_files
let total_arrow_files_size = staging_files
.values()
.map(|v| {
v.iter()
.map(|file| file.metadata().unwrap().len())
.sum::<u64>()
})
.sum::<u64>();
metrics::STORAGE_SIZE
.with_label_values(&["staging", &self.stream_name, "arrows"])
.set(total_arrow_files_size as i64);

// warn!("staging files-\n{staging_files:?}\n");
for (parquet_path, arrow_files) in staging_files {
metrics::STAGING_FILES
.with_label_values(&[&self.stream_name])
.set(arrow_files.len() as i64);

for file in &arrow_files {
let file_size = file.metadata().unwrap().len();
let file_type = file.extension().unwrap().to_str().unwrap();

metrics::STORAGE_SIZE
.with_label_values(&["staging", &self.stream_name, file_type])
.add(file_size as i64);
}

let record_reader = MergedReverseRecordReader::try_new(&arrow_files);
if record_reader.readers.is_empty() {
continue;
Expand Down Expand Up @@ -494,6 +500,7 @@ impl Stream {
"Couldn't rename part file: {part_path:?} -> {parquet_path:?}, error = {e}"
);
}

for file in arrow_files {
// warn!("file-\n{file:?}\n");
let file_size = file.metadata().unwrap().len();
Expand Down
5 changes: 3 additions & 2 deletions src/storage/object_storage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ use datafusion::{datasource::listing::ListingTableUrl, execution::runtime_env::R
use once_cell::sync::OnceCell;
use relative_path::RelativePath;
use relative_path::RelativePathBuf;
use tracing::{debug, error, warn};
use tracing::info;
use tracing::{error, warn};
use ulid::Ulid;

use crate::alerts::AlertConfig;
Expand Down Expand Up @@ -718,7 +719,7 @@ pub trait ObjectStorage: Debug + Send + Sync + 'static {

// get all streams
for stream_name in PARSEABLE.streams.list() {
debug!("Starting object_store_sync for stream- {stream_name}");
info!("Starting object_store_sync for stream- {stream_name}");

let stream = PARSEABLE.get_or_create_stream(&stream_name);
let custom_partition = stream.get_custom_partition();
Expand Down
Loading