Skip to content

Commit

Permalink
fix replacement metrics
Browse files Browse the repository at this point in the history
  • Loading branch information
mouseless0x committed Feb 4, 2025
1 parent 21f837c commit 4df2ea3
Showing 1 changed file with 15 additions and 10 deletions.
25 changes: 15 additions & 10 deletions src/executor/executorManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -753,16 +753,6 @@ export class ExecutorManager {
this.senderManager.markWalletProcessed(txInfo.executor)
}

// Log metrics.
const replaceStatus =
bundleResult && bundleResult.status === "bundle_success"
? "succeeded"
: "failed"

this.metrics.replacedTransactions
.labels({ reason, status: replaceStatus })
.inc()

// Check if the transaction is potentially included.
const nonceTooLow =
bundleResult.status === "bundle_submission_failure" &&
Expand All @@ -778,6 +768,21 @@ export class ExecutorManager {

const potentiallyIncluded = nonceTooLow || allOpsFailedSimulation

// log metrics
const replaceStatus = (() => {
switch (true) {
case potentiallyIncluded:
return "potentially_already_included"
case bundleResult?.status === "bundle_success":
return "replaced"
default:
return "failed"
}
})()
this.metrics.replacedTransactions
.labels({ reason, status: replaceStatus })
.inc()

if (potentiallyIncluded) {
this.logger.info(
{ oldTxHash },
Expand Down

0 comments on commit 4df2ea3

Please sign in to comment.