Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: cherry pick PR#3422 feat(logging): enhanced logging upon receiving responses from the Mirror Node server (#3422) to release/0.64 #3426

Merged
merged 1 commit into from
Jan 27, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@

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 @@

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 @@
} 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 @@
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
Loading