Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: operation_status metric inaccuracy #5002

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 9 additions & 6 deletions rust/main/agents/relayer/src/msg/op_queue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<PendingOperationStatus>) {
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));
}
Expand Down Expand Up @@ -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<PendingOperationStatus>,
) -> 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,
])
}
Expand Down
Loading