Skip to content

Commit f792823

Browse files
committed
HARMONY-1980: Add timing logging for external validation
1 parent 7941da4 commit f792823

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

services/harmony/app/middleware/external-validation.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ export async function externalValidation(
1717
const url = context?.serviceConfig?.external_validation_url;
1818
if (!url) return next();
1919

20+
req.context.logger.info('timing.external-validation.start');
21+
const startTime = new Date().getTime();
2022
try {
2123
await axios.post(
2224
url,
@@ -30,13 +32,15 @@ export async function externalValidation(
3032
} catch (e) {
3133
req.context.logger.error('External validation failed');
3234
if (e.response) {
35+
req.context.logger.error(`Validation response: ${JSON.stringify(e.response.data, null, 2)}`);
3336
return next(new ExternalValidationError(e.response.data, e.response.status));
3437
} else {
35-
req.context.logger.error('THROWING 500 ERROR');
36-
req.context.logger.error(JSON.stringify(e, null, 2));
37-
req.context.logger.error(e);
38+
req.context.logger.error(`Error calling validation endpoint: ${url}.`);
3839
return next(e);
3940
}
41+
} finally {
42+
const durationMs = new Date().getTime() - startTime;
43+
req.context.logger.info('timing.external-validation.end', { durationMs });
4044
}
4145

4246
return next();

0 commit comments

Comments
 (0)