Skip to content

Commit

Permalink
dex: correct placement of arb metrics emission (#4535)
Browse files Browse the repository at this point in the history
We noticed there were no metrics being emitted for the cost of the arb
search when no arb was found.

This fixes that, and should be backported into the next point release.

- [x] If this code contains consensus-breaking changes, I have added the
"consensus-breaking" label. Otherwise, I declare my belief that there
are not consensus-breaking changes, for the following reason:

  > Only changes metrics emission
  • Loading branch information
hdevalence authored and conorsch committed Jun 4, 2024
1 parent 13f81d0 commit 2633ea3
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion crates/core/component/dex/src/component/arb.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,11 @@ pub trait Arbitrage: StateWrite + Sized {
.checked_sub(&filled_input)
.expect("filled input should always be <= flash loan amount");

// Record the duration of the arb execution now, since we've computed it
// and we might return early if it's zero-valued, but in that case we still
// want to record how long we spent looking for it.
metrics::histogram!(metrics::DEX_ARB_DURATION).record(arb_start.elapsed());

// Because we're trading the arb token to itself, the total output is the
// output from the route-and-fill, plus the unfilled input.
let total_output = output + unfilled_input;
Expand Down Expand Up @@ -134,7 +139,6 @@ pub trait Arbitrage: StateWrite + Sized {

// Emit an ABCI event detailing the arb execution.
self_mut.record_proto(event::arb_execution(height, se));
metrics::histogram!(metrics::DEX_ARB_DURATION).record(arb_start.elapsed());
return Ok(Value {
amount: arb_profit,
asset_id: arb_token,
Expand Down

0 comments on commit 2633ea3

Please sign in to comment.