Skip to content

Commit

Permalink
add quote latency metrics within onchain quote provider (#529)
Browse files Browse the repository at this point in the history
  • Loading branch information
jsy1218 committed Apr 15, 2024
1 parent c38259c commit 409f150
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/providers/on-chain-quote-provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ export class OnChainQuoteProvider implements IOnChainQuoteProvider {
protected successRateFailureOverrides: FailureOverrides = DEFAULT_SUCCESS_RATE_FAILURE_OVERRIDES,
protected blockNumberConfig: BlockNumberConfig = DEFAULT_BLOCK_NUMBER_CONFIGS,
protected quoterAddressOverride?: string,
protected metricsPrefix?: string
protected metricsPrefix: string = '' // default metric prefix to be empty string
) {}

private getQuoterAddress(useMixedRouteQuoter: boolean): string {
Expand Down Expand Up @@ -430,6 +430,8 @@ export class OnChainQuoteProvider implements IOnChainQuoteProvider {
MetricLoggerUnit.Count
);

const startTime = Date.now();

let haveRetriedForSuccessRate = false;
let haveRetriedForBlockHeader = false;
let blockHeaderRetryAttemptNumber = 0;
Expand Down Expand Up @@ -772,6 +774,13 @@ export class OnChainQuoteProvider implements IOnChainQuoteProvider {
amounts
);

const endTime = Date.now();
metric.putMetric(
`${this.metricsPrefix}QuoteLatency`,
endTime - startTime,
MetricLoggerUnit.Milliseconds
)

metric.putMetric(
`${this.metricsPrefix}QuoteApproxGasUsedPerSuccessfulCall`,
approxGasUsedPerSuccessCall,
Expand Down

0 comments on commit 409f150

Please sign in to comment.