Skip to content

Commit

Permalink
Add stats for Elliptic (#2026)
Browse files Browse the repository at this point in the history
  • Loading branch information
Christopher-Li authored Aug 5, 2024
1 parent 5b0ae75 commit 10d9f1e
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions indexer/packages/compliance/src/clients/elliptic-provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,17 @@ export class EllipticProviderClient extends ComplianceClient {
message: 'Malformed response from Elliptic',
response,
});
stats.increment(
`${config.SERVICE_NAME}.get_elliptic_risk_score.status_code`,
{ status: 'malformed' },
);
throw new ComplianceClientError('Malformed response');
}

stats.increment(
`${config.SERVICE_NAME}.get_elliptic_risk_score.status_code`,
{ status: '200' },
);
if (riskScore === null) {
return NO_RULES_TRIGGERED_RISK_SCORE;
}
Expand All @@ -86,14 +94,26 @@ export class EllipticProviderClient extends ComplianceClient {
error?.response?.status === 404 &&
error?.response?.data?.name === 'NotInBlockchain'
) {
stats.increment(
`${config.SERVICE_NAME}.get_elliptic_risk_score.status_code`,
{ status: '404' },
);
return NO_RULES_TRIGGERED_RISK_SCORE;
}

if (error?.response?.status === 429) {
stats.increment(
`${config.SERVICE_NAME}.get_elliptic_risk_score.status_code`,
{ status: '429' },
);
throw new TooManyRequestsError('Too many requests');
}

if (error?.response?.status === 500 && retries < config.ELLIPTIC_MAX_RETRIES) {
stats.increment(
`${config.SERVICE_NAME}.get_elliptic_risk_score.status_code`,
{ status: '500' },
);
return this.getRiskScore(address, retries + 1);
}

Expand Down

0 comments on commit 10d9f1e

Please sign in to comment.