From 30b1a212bad1d5acc44f8432b25050f21bd6c17a Mon Sep 17 00:00:00 2001 From: Golda Velez Date: Tue, 30 May 2023 10:55:05 -0700 Subject: [PATCH] clean changes for metrics on eth transactions --- .../blockchain/ethereum/ethereum-blockchain-service.ts | 4 ++++ src/settings.ts | 6 ++++++ 2 files changed, 10 insertions(+) diff --git a/src/services/blockchain/ethereum/ethereum-blockchain-service.ts b/src/services/blockchain/ethereum/ethereum-blockchain-service.ts index 41463d456..1b6101874 100644 --- a/src/services/blockchain/ethereum/ethereum-blockchain-service.ts +++ b/src/services/blockchain/ethereum/ethereum-blockchain-service.ts @@ -13,7 +13,9 @@ import { TransactionResponse, TransactionReceipt, } from '@ethersproject/abstract-provider' +import { ServiceMetrics as Metrics } from '@ceramicnetwork/observability' import { Utils } from '../../../utils.js' +import { METRIC_NAMES } from '../../../settings.js' const BASE_CHAIN_ID = 'eip155' const TX_FAILURE = 0 @@ -410,6 +412,7 @@ export class EthereumBlockchainService implements BlockchainService { const txData = await this._buildTransactionRequest(rootCid) const txResponses: Array = [] + Metrics.count(METRIC_NAMES.ETH_REQUEST_TOTAL, 1) return this.withWalletBalance((walletBalance) => { return attempt(MAX_RETRIES, async (attemptNum) => { try { @@ -420,6 +423,7 @@ export class EthereumBlockchainService implements BlockchainService { } catch (err: any) { logger.err(err) const { code } = err + Metrics.count(METRIC_NAMES.ETH_REQUEST_ERROR_TOTAL, 1, {'error_code': code}) switch (code) { case ErrorCode.INSUFFICIENT_FUNDS: return handleInsufficientFundsError(txData, walletBalance) diff --git a/src/settings.ts b/src/settings.ts index 40f87cf6d..ac07366fb 100644 --- a/src/settings.ts +++ b/src/settings.ts @@ -48,6 +48,12 @@ export enum METRIC_NAMES { ANCHOR_REQUESTS_BATCH_TIME = 'anchor_requests_batch_time', ANCHOR_REQUESTS_BATCH_FAILURE_TIME = 'anchor_requests_batch_failure_time', + // *******************************************************************// + // Ethereum Blockchain Service + + ETH_REQUEST_TOTAL = 'eth_request_total', + ETH_REQUEST_ERROR_TOTAL = 'eth_request_error_total', + // *******************************************************************// // Scheduler Service SCHEDULER_TASK_UNCAUGHT_ERROR = 'scheduler_task_uncaught_error',