Skip to content

Commit

Permalink
chore(logging): enhanced logging upon receiving responses from the Mi…
Browse files Browse the repository at this point in the history
…rror Node server

Signed-off-by: Logan Nguyen <[email protected]>
  • Loading branch information
quiet-node committed Jan 26, 2025
1 parent fe6c0cf commit 76c0394
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions packages/relay/src/lib/clients/mirrorNodeClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,13 @@ export class MirrorNodeClient {

const ms = Date.now() - start;
if (this.logger.isLevelEnabled('debug')) {
this.logger.debug(`${requestDetails.formattedRequestId} [${method}] ${path} ${response.status} ${ms} ms`);
this.logger.debug(
`${
requestDetails.formattedRequestId
} Successfully received response from mirror node server: method=${method}, path=${path}, status=${
response.status
}, duration:${ms}ms, data:${JSON.stringify(response.data)}`,
);
}
this.mirrorResponseHistogram.labels(pathLabel, response.status?.toString()).observe(ms);
return response.data;
Expand Down Expand Up @@ -428,7 +434,9 @@ export class MirrorNodeClient {

if (error.response && acceptedErrorResponses?.includes(effectiveStatusCode)) {
if (this.logger.isLevelEnabled('debug')) {
this.logger.debug(`${requestIdPrefix} [${method}] ${path} ${effectiveStatusCode} status`);
this.logger.debug(

Check warning on line 437 in packages/relay/src/lib/clients/mirrorNodeClient.ts

View check run for this annotation

Codecov / codecov/patch

packages/relay/src/lib/clients/mirrorNodeClient.ts#L437

Added line #L437 was not covered by tests
`${requestIdPrefix} An accepted error occurred while communicating with the mirror node server: method=${method}, path=${path}, status=${effectiveStatusCode}`,
);
}
return null;
}
Expand All @@ -445,7 +453,7 @@ export class MirrorNodeClient {
} else {
this.logger.error(
new Error(error.message),
`${requestIdPrefix} [${method}] ${path} ${effectiveStatusCode} status`,
`${requestIdPrefix} Error encountered while communicating with the mirror node server: method=${method}, path=${path}, status=${effectiveStatusCode}`,
);
}

Expand Down Expand Up @@ -1036,6 +1044,7 @@ export class MirrorNodeClient {
if (address === ethers.ZeroAddress) return [];

const queryParams = this.prepareLogsParams(contractLogsResultsParams, limitOrderParams);

const apiEndpoint = MirrorNodeClient.GET_CONTRACT_RESULT_LOGS_BY_ADDRESS_ENDPOINT.replace(
MirrorNodeClient.ADDRESS_PLACEHOLDER,
address,
Expand Down

0 comments on commit 76c0394

Please sign in to comment.