From 1d63e88115e4a7962d3a5252449f106a4b7dc154 Mon Sep 17 00:00:00 2001 From: Yevhen Shulha Date: Sat, 23 Nov 2024 00:03:00 +0200 Subject: [PATCH] fix: add latency logs --- src/pricing-helper.ts | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/pricing-helper.ts b/src/pricing-helper.ts index 3c3343165..6d8aa27b4 100644 --- a/src/pricing-helper.ts +++ b/src/pricing-helper.ts @@ -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; @@ -217,6 +218,7 @@ export class PricingHelper { return resolve(null); } + const startTime = performance.now(); dexInstance .getPricesVolume( from, @@ -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); }