Turn upload_queue_items_metric into a regular function

This commit is contained in:
Heikki Linnakangas
2022-11-22 14:45:22 +02:00
parent 6b7cbec9b3
commit 3c4680b718

View File

@@ -364,19 +364,6 @@ impl std::fmt::Display for UploadOp {
}
}
macro_rules! upload_queue_items_metric {
($remote_timeline_client:expr, $delta:expr) => {{
let remote_timeline_client = &$remote_timeline_client;
REMOTE_UPLOAD_QUEUE_UNFINISHED_TASKS
.get_metric_with_label_values(&[
&remote_timeline_client.tenant_id.to_string(),
&remote_timeline_client.timeline_id.to_string(),
])
.unwrap()
.add($delta)
}}
}
impl RemoteTimelineClient {
/// Initialize the upload queue for a remote storage that already received
/// an index file upload, i.e., it's not empty.
@@ -499,7 +486,7 @@ impl RemoteTimelineClient {
upload_queue
.queued_operations
.push_back(UploadOp::UploadMetadata(index_part, disk_consistent_lsn));
upload_queue_items_metric!(self, 1);
self.upload_queue_items_metric(1);
info!(
"scheduled metadata upload with {} files",
@@ -547,7 +534,7 @@ impl RemoteTimelineClient {
PathBuf::from(path),
layer_metadata.clone(),
));
upload_queue_items_metric!(self, 1);
self.upload_queue_items_metric(1);
info!("scheduled layer file upload {}", path.display());
@@ -588,14 +575,14 @@ impl RemoteTimelineClient {
upload_queue
.queued_operations
.push_back(UploadOp::UploadMetadata(index_part, disk_consistent_lsn));
upload_queue_items_metric!(self, 1);
self.upload_queue_items_metric(1);
// schedule the actual deletions
for path in paths {
upload_queue
.queued_operations
.push_back(UploadOp::Delete(PathBuf::from(path)));
upload_queue_items_metric!(self, 1);
self.upload_queue_items_metric(1);
info!("scheduled layer file deletion {}", path.display());
}
@@ -710,7 +697,7 @@ impl RemoteTimelineClient {
false,
async move {
self_rc.perform_upload_task(task).await;
upload_queue_items_metric!(self_rc, -1);
self_rc.upload_queue_items_metric(-1);
Ok(())
},
);
@@ -833,6 +820,16 @@ impl RemoteTimelineClient {
self.launch_queued_tasks(upload_queue);
}
}
fn upload_queue_items_metric(&self, delta: i64) {
REMOTE_UPLOAD_QUEUE_UNFINISHED_TASKS
.get_metric_with_label_values(&[
&self.tenant_id.to_string(),
&self.timeline_id.to_string(),
])
.unwrap()
.add(delta)
}
}
///