Skip to content

Commit 3e3f326

Browse files
committed
additional datapoint_error
1 parent 81454df commit 3e3f326

File tree

2 files changed

+46
-3
lines changed

2 files changed

+46
-3
lines changed

tip-router-operator-cli/src/process_epoch.rs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,13 @@ pub async fn loop_stages(
119119
Ok(info) => break info,
120120
Err(e) => {
121121
error!("Error getting epoch info from RPC. Retrying...");
122+
datapoint_error!(
123+
"tip_router_cli.get_epoch_info",
124+
("operator_address", cli.operator_address.clone(), String),
125+
("status", "error", String),
126+
("error", e.to_string(), String),
127+
"cluster" => &cli.cluster,
128+
);
122129
tokio::time::sleep(Duration::from_secs(5)).await;
123130
}
124131
}
@@ -131,6 +138,13 @@ pub async fn loop_stages(
131138
Ok(schedule) => break schedule,
132139
Err(e) => {
133140
error!("Error getting epoch schedule from RPC. Retrying...");
141+
datapoint_error!(
142+
"tip_router_cli.get_epoch_schedule",
143+
("operator_address", cli.operator_address.clone(), String),
144+
("status", "error", String),
145+
("error", e.to_string(), String),
146+
"cluster" => &cli.cluster,
147+
);
134148
tokio::time::sleep(Duration::from_secs(5)).await;
135149
}
136150
}
@@ -333,6 +347,15 @@ pub async fn loop_stages(
333347
"Failed to submit epoch {} to NCN: {:?}",
334348
epoch_to_process, e
335349
);
350+
datapoint_error!(
351+
"tip_router_cli.cast_vote",
352+
("operator_address", operator_address.to_string(), String),
353+
("epoch", epoch_to_process, i64),
354+
("status", "error", String),
355+
("error", e.to_string(), String),
356+
("state", "cast_vote", String),
357+
"cluster" => &cli.cluster,
358+
);
336359
}
337360
stage = OperatorState::WaitForNextEpoch;
338361
}

tip-router-operator-cli/src/submit.rs

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -136,15 +136,35 @@ pub async fn submit_to_ncn(
136136
}
137137
};
138138

139-
let ballot_box = BallotBox::try_from_slice_unchecked(&ballot_box_account.data)
140-
.map_err(|e| anyhow::anyhow!("Failed to deserialize ballot box: {:?}", e))?;
139+
let ballot_box =
140+
BallotBox::try_from_slice_unchecked(&ballot_box_account.data).map_err(|e| {
141+
datapoint_error!(
142+
"tip_router_cli.ballot_box_deserialize_error",
143+
("operator_address", operator_address.to_string(), String),
144+
("epoch", tip_router_target_epoch, i64),
145+
("status", "error", String),
146+
("error", format!("{:?}", e), String),
147+
"cluster" => cluster,
148+
);
149+
anyhow::anyhow!("Failed to deserialize ballot box: {:?}", e)
150+
})?;
141151

142152
let is_voting_valid = ballot_box
143153
.is_voting_valid(
144154
epoch_info.absolute_slot,
145155
config.valid_slots_after_consensus(),
146156
)
147-
.map_err(|e| anyhow::anyhow!("Failed to determine if voting is valid: {:?}", e))?;
157+
.map_err(|e| {
158+
datapoint_error!(
159+
"tip_router_cli.voting_validity_error",
160+
("operator_address", operator_address.to_string(), String),
161+
("epoch", tip_router_target_epoch, i64),
162+
("status", "error", String),
163+
("error", format!("{:?}", e), String),
164+
"cluster" => cluster,
165+
);
166+
anyhow::anyhow!("Failed to determine if voting is valid: {:?}", e)
167+
})?;
148168

149169
// If exists, look for vote from current operator
150170
let vote = ballot_box

0 commit comments

Comments
 (0)