Skip to content

Commit

Permalink
chore: cherry pick PR#3422 feat(logging): enhanced logging upon recei…
Browse files Browse the repository at this point in the history
…ving responses from the Mirror Node server (#3422) to release/0.64 (#3426)

chore(logging): enhanced logging upon receiving responses from the Mirror Node server (#3422)

Signed-off-by: Logan Nguyen <logan.nguyen@swirldslabs.com>
  • Loading branch information
quiet-node authored Jan 27, 2025
1 parent 6bd832c commit c7f3287
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(
`${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 c7f3287

Please sign in to comment.