Skip to content

Commit ce9397d

Browse files
committed
fix(gas): dont include error iters in metric
1 parent 544ed5b commit ce9397d

File tree

1 file changed

+13
-12
lines changed
  • engine/packages/gasoline/src/builder/workflow

1 file changed

+13
-12
lines changed

engine/packages/gasoline/src/builder/workflow/lupe.rs

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ impl<'a, S: Serialize + DeserializeOwned> LoopBuilder<'a, S> {
117117

118118
// Used to defer loop upsertion for parallelization
119119
let mut loop_event_upsert_fut = None;
120-
let mut iteration_dt = Duration::ZERO;
120+
let mut iteration_dt: Option<Duration> = None;
121121

122122
loop {
123123
ctx.check_stop()?;
@@ -155,7 +155,7 @@ impl<'a, S: Serialize + DeserializeOwned> LoopBuilder<'a, S> {
155155
loop_event_commit_res,
156156
loop_event_upsert_res,
157157
branch_commit_res,
158-
(loop_res, cb_dt),
158+
(cb_res, cb_dt),
159159
) = tokio::join!(
160160
async {
161161
if let Some(loop_event_init_fut) = loop_event_init_fut.take() {
@@ -186,21 +186,23 @@ impl<'a, S: Serialize + DeserializeOwned> LoopBuilder<'a, S> {
186186
)
187187
.await?;
188188

189-
// Only record iteration duration if its not a replay
190-
metrics::LOOP_ITERATION_DURATION
191-
.with_label_values(&[&ctx.name().to_string()])
192-
.observe(iteration_dt.as_secs_f64());
189+
if let Some(iteration_dt) = &iteration_dt {
190+
// Only record iteration duration if its not a replay
191+
metrics::LOOP_ITERATION_DURATION
192+
.with_label_values(&[&ctx.name().to_string()])
193+
.observe(iteration_dt.as_secs_f64());
194+
}
193195
}
194196

195197
anyhow::Ok(())
196198
},
197199
async {
198200
let iteration_start_instant = Instant::now();
199201

200-
(
201-
cb(&mut iteration_branch, &mut state).await,
202-
iteration_start_instant.elapsed(),
203-
)
202+
let cb_res = cb(&mut iteration_branch, &mut state).await;
203+
let cb_dt = cb_res.is_ok().then(|| iteration_start_instant.elapsed());
204+
205+
(cb_res, cb_dt)
204206
}
205207
);
206208

@@ -210,8 +212,7 @@ impl<'a, S: Serialize + DeserializeOwned> LoopBuilder<'a, S> {
210212

211213
iteration_dt = cb_dt;
212214

213-
// Run loop
214-
match loop_res? {
215+
match cb_res? {
215216
Loop::Continue => {
216217
iteration += 1;
217218

0 commit comments

Comments
 (0)