From 3c4680b71877d91a746499643b616ac8bceffe0f Mon Sep 17 00:00:00 2001 From: Heikki Linnakangas Date: Tue, 22 Nov 2022 14:45:22 +0200 Subject: [PATCH] Turn upload_queue_items_metric into a regular function --- pageserver/src/storage_sync.rs | 33 +++++++++++++++------------------ 1 file changed, 15 insertions(+), 18 deletions(-) diff --git a/pageserver/src/storage_sync.rs b/pageserver/src/storage_sync.rs index 8e563f4bd6..611e961f4c 100644 --- a/pageserver/src/storage_sync.rs +++ b/pageserver/src/storage_sync.rs @@ -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) + } } ///