diff --git a/src/domain/addContract.ts b/src/domain/addContract.ts index d4ce36d..919142e 100644 --- a/src/domain/addContract.ts +++ b/src/domain/addContract.ts @@ -44,14 +44,14 @@ export async function addContract( event: ConditionalOrderCreatedEvent ) { const { chainId } = context; - await measureTime( - () => _addContract(context, event), - [chainId.toString()], - addContractsRunDurationSeconds, - addContractRunsTotal, - handleExecutionError, - addContractsErrorsTotal - ); + await measureTime({ + action: () => _addContract(context, event), + labelValues: [chainId.toString()], + durationMetric: addContractsRunDurationSeconds, + totalRunsMetric: addContractRunsTotal, + errorHandler: handleExecutionError, + errorMetric: addContractsErrorsTotal, + }); } async function _addContract( diff --git a/src/domain/checkForAndPlaceOrder.ts b/src/domain/checkForAndPlaceOrder.ts index 0961500..c0c5b7f 100644 --- a/src/domain/checkForAndPlaceOrder.ts +++ b/src/domain/checkForAndPlaceOrder.ts @@ -259,8 +259,8 @@ async function _processConditionalOrder( // Unsupported Order Type (unknown handler) // For now, fallback to legacy behavior // TODO: Decide in the future what to do. Probably, move the error handling to the SDK and kill the poll Legacy - pollResult = await measureTime( - () => + pollResult = await measureTime({ + action: () => _pollLegacy( context, owner, @@ -269,10 +269,15 @@ async function _processConditionalOrder( offchainInput, orderRef ), - metricLabels, - pollingOnChainDurationSeconds, - pollingOnChainChecksTotal - ); + labelValues: metricLabels, + durationMetric: pollingOnChainDurationSeconds, + totalRunsMetric: pollingOnChainChecksTotal, + }); + } + + // This should be impossible to reach, but satisfies the compiler + if (pollResult === undefined) { + throw new Error("Unexpected error: pollResult is undefined"); } // Error polling diff --git a/src/utils/utils.spec.ts b/src/utils/utils.spec.ts index a0048c6..ae666a4 100644 --- a/src/utils/utils.spec.ts +++ b/src/utils/utils.spec.ts @@ -100,7 +100,7 @@ describe("handle on-chain custom errors", () => { revertData: abiToSelector( CUSTOM_ERROR_ABI_MAP[CustomErrorSelectors.SINGLE_ORDER_NOT_AUTHED] ), - metricLabels: [], + metricLabels: ["chain_id", "handler", "owner", "id"], }; it("should pass a known selector correctly", () => {