Skip to content

Commit

Permalink
fix: add latency logs
Browse files Browse the repository at this point in the history
  • Loading branch information
JackieJoo committed Nov 22, 2024
1 parent c834699 commit 1d63e88
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/pricing-helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import {
import { DexAdapterService } from './dex';
import { IDex, IRouteOptimizer } from './dex/idex';
import { isSrcTokenTransferFeeToBeExchanged } from './utils';
import { performance } from 'perf_hooks';

export class PricingHelper {
logger: Logger;
Expand Down Expand Up @@ -217,6 +218,7 @@ export class PricingHelper {
return resolve(null);
}

const startTime = performance.now();
dexInstance
.getPricesVolume(
from,
Expand All @@ -229,6 +231,19 @@ export class PricingHelper {
)
.then(poolPrices => {
try {
const endTime = performance.now();
const duration = endTime - startTime;
this.logger.info(
JSON.stringify({
message: 'Latency.getPricesVolume.dex-lib',
latencyMs: parseFloat(duration.toFixed(2)),
dex: key,
network: this.dexAdapterService.network,
fromToken: from.symbol || from.address,
toToken: to.symbol || to.address,
success: !!poolPrices,
}),
);
if (!poolPrices || !rollupL1ToL2GasRatio) {
return resolve(poolPrices);
}
Expand Down

0 comments on commit 1d63e88

Please sign in to comment.