Skip to content

Commit 7845aff

Browse files
authored
Add staging file size (#329)
1 parent 5b85262 commit 7845aff

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

server/src/metrics/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ lazy_static! {
4040
.expect("metric can be created");
4141
pub static ref STORAGE_SIZE: IntGaugeVec = IntGaugeVec::new(
4242
Opts::new("storage_size", "Storage size bytes").namespace(METRICS_NAMESPACE),
43-
&["stream", "format"]
43+
&["type", "stream", "format"]
4444
)
4545
.expect("metric can be created");
4646
pub static ref STAGING_FILES: IntGaugeVec = IntGaugeVec::new(
@@ -117,7 +117,7 @@ pub fn load_from_global_stats() {
117117
.with_label_values(&[&stream_name, "json"])
118118
.set(stats.ingestion as i64);
119119
STORAGE_SIZE
120-
.with_label_values(&[&stream_name, "parquet"])
120+
.with_label_values(&["data", &stream_name, "parquet"])
121121
.set(stats.storage as i64)
122122
}
123123
}

server/src/storage/object_storage.rs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -268,6 +268,15 @@ pub trait ObjectStorage: Sync + 'static {
268268
.with_label_values(&[stream])
269269
.set(files.len() as i64);
270270

271+
for file in &files {
272+
let file_size = file.metadata().unwrap().len();
273+
let file_type = file.extension().unwrap().to_str().unwrap();
274+
275+
STORAGE_SIZE
276+
.with_label_values(&["staging", stream, file_type])
277+
.add(file_size as i64);
278+
}
279+
271280
let record_reader = MergedRecordReader::try_new(&files).unwrap();
272281

273282
let mut parquet_table = CACHED_FILES.lock().unwrap();
@@ -355,7 +364,7 @@ pub trait ObjectStorage: Sync + 'static {
355364
let stats = STREAM_INFO.read().unwrap().get(stream).map(|metadata| {
356365
metadata.stats.add_storage_size(compressed_size);
357366
STORAGE_SIZE
358-
.with_label_values(&[stream, "parquet"])
367+
.with_label_values(&["data", stream, "parquet"])
359368
.add(compressed_size as i64);
360369
Stats::from(&metadata.stats)
361370
});

0 commit comments

Comments
 (0)