Skip to content

Commit

Permalink
fix for staging size metrics
Browse files Browse the repository at this point in the history
- to subtract the size of the arrow file removed from staging
fix for GET /cache
- to return error in case global cache is not set
  • Loading branch information
nikhilsinhaparseable committed Apr 29, 2024
1 parent b251e05 commit b5fa070
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
10 changes: 10 additions & 0 deletions server/src/handlers/http/logstream.rs
Original file line number Diff line number Diff line change
Expand Up @@ -338,6 +338,16 @@ pub async fn put_retention(

pub async fn get_cache_enabled(req: HttpRequest) -> Result<impl Responder, StreamError> {
let stream_name: String = req.match_info().get("logstream").unwrap().parse().unwrap();

match CONFIG.parseable.mode {
Mode::Ingest | Mode::All => {
if CONFIG.parseable.local_cache_path.is_none() {
return Err(StreamError::CacheNotEnabled(stream_name));
}
}
_ => {}
}

let cache_enabled = STREAM_INFO.cache_enabled(&stream_name)?;
Ok((web::Json(cache_enabled), StatusCode::OK))
}
Expand Down
8 changes: 7 additions & 1 deletion server/src/storage/staging.rs
Original file line number Diff line number Diff line change
Expand Up @@ -247,10 +247,16 @@ pub fn convert_disk_files_to_parquet(
writer.close()?;

for file in files {
if fs::remove_file(file).is_err() {
let file_size = file.metadata().unwrap().len();
let file_type = file.extension().unwrap().to_str().unwrap();

if fs::remove_file(file.clone()).is_err() {
log::error!("Failed to delete file. Unstable state");
process::abort()
}
metrics::STORAGE_SIZE
.with_label_values(&["staging", stream, file_type])
.sub(file_size as i64);
}
}

Expand Down

0 comments on commit b5fa070

Please sign in to comment.