From 258e0e2aa96bb9ffa32f8dd3f71f7a970b44ae44 Mon Sep 17 00:00:00 2001 From: Daniel Savu <23065004+daniel-savu@users.noreply.github.com> Date: Fri, 13 Dec 2024 13:07:50 +0000 Subject: [PATCH 1/2] fix: operation_status metric inaccuracy --- rust/main/agents/relayer/src/msg/op_queue.rs | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/rust/main/agents/relayer/src/msg/op_queue.rs b/rust/main/agents/relayer/src/msg/op_queue.rs index 95025d391c..913d7fa290 100644 --- a/rust/main/agents/relayer/src/msg/op_queue.rs +++ b/rust/main/agents/relayer/src/msg/op_queue.rs @@ -29,10 +29,8 @@ impl OpQueue { /// it's very likely that its status has just changed, so this forces the caller to consider the new status #[instrument(skip(self), ret, fields(queue_label=%self.queue_metrics_label), level = "trace")] pub async fn push(&self, mut op: QueueOperation, new_status: Option) { - op.set_status_and_update_metrics( - new_status, - Arc::new(self.get_operation_metric(op.as_ref())), - ); + let new_metric = Arc::new(self.get_new_operation_metric(op.as_ref(), new_status)); + op.set_status_and_update_metrics(new_status, new_metric); self.queue.lock().await.push(Reverse(op)); } @@ -99,12 +97,17 @@ impl OpQueue { } /// Get the metric associated with this operation - fn get_operation_metric(&self, operation: &dyn PendingOperation) -> IntGauge { + fn get_new_operation_metric( + &self, + operation: &dyn PendingOperation, + new_status: Option, + ) -> IntGauge { let (destination, app_context) = operation.get_operation_labels(); + let new_metric_status = new_status.unwrap_or(operation.status()); self.metrics.with_label_values(&[ &destination, &self.queue_metrics_label, - &operation.status().to_string(), + &new_metric_status.to_string(), &app_context, ]) } From 9d7cfd2144ef6e3c399b8958866df3f066613069 Mon Sep 17 00:00:00 2001 From: Daniel Savu <23065004+daniel-savu@users.noreply.github.com> Date: Fri, 13 Dec 2024 13:33:12 +0000 Subject: [PATCH 2/2] fix build --- rust/main/agents/relayer/src/msg/op_queue.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rust/main/agents/relayer/src/msg/op_queue.rs b/rust/main/agents/relayer/src/msg/op_queue.rs index 913d7fa290..99c9dde39f 100644 --- a/rust/main/agents/relayer/src/msg/op_queue.rs +++ b/rust/main/agents/relayer/src/msg/op_queue.rs @@ -29,7 +29,7 @@ impl OpQueue { /// it's very likely that its status has just changed, so this forces the caller to consider the new status #[instrument(skip(self), ret, fields(queue_label=%self.queue_metrics_label), level = "trace")] pub async fn push(&self, mut op: QueueOperation, new_status: Option) { - let new_metric = Arc::new(self.get_new_operation_metric(op.as_ref(), new_status)); + let new_metric = Arc::new(self.get_new_operation_metric(op.as_ref(), new_status.clone())); op.set_status_and_update_metrics(new_status, new_metric); self.queue.lock().await.push(Reverse(op));