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

#3889 - Increase Logging for SFTP and file handling #3897

Merged

Conversation

andrewsignori-aot
Copy link
Collaborator

@andrewsignori-aot andrewsignori-aot commented Nov 6, 2024

Main PR Goal

  • Increase the log level at the SFTPIntegrationBase without disrupting the consumer's methods and try to limit the amount of refactoring.
  • Deploy to PROD in the next possible release to allow troubleshooting of current intermittent issues while archiving files.

Changes

  • Adapted the LoggerService.error to receive a friendly error and log the error itself, keeping it compatible with the existing methods.
  • Added log messages to all base SFTP operations in the SFTPIntegrationBase. The errors are reshown keeping the current behavior for current method consumers.
  • Adjusted the API mais.ts that was using the log context.
  • Adjusted the global error handler to generate only one log entry instead of three.
  • Even though the SFTPIntegrationBase method is now generating more logs, the archive operation error handling was adjusted to ensure the exception details are logged.
  • Small refactor to stop passing the SFTP_ARCHIVE_DIRECTORY for every archive method.

@andrewsignori-aot andrewsignori-aot self-assigned this Nov 6, 2024
@andrewsignori-aot andrewsignori-aot added the Prod Required Strongly recommended for production. label Nov 6, 2024
@andrewsignori-aot andrewsignori-aot marked this pull request as ready for review November 6, 2024 00:48
@dheepak-aot dheepak-aot added the SIMS-Api SIMS-Api label Nov 6, 2024
Copy link
Collaborator

@dheepak-aot dheepak-aot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good Job @andrewsignori-aot . 2 minor comments and a question.

Comment on lines +66 to +68
} catch (error) {
this.logger.error(`Error uploading file ${remoteFilePath}.`, error);
throw error;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

Comment on lines 34 to 46
error(message: unknown, error?: unknown, context?: string): void {
const errorBuilder = new StringBuilder();
if (typeof message === "string") {
errorBuilder.appendLine(message);
} else {
errorBuilder.appendLine(parseJSONError(message));
}
if (error) {
errorBuilder.appendLine(parseJSONError(error));
}
super.error(errorBuilder.toString(), context);
}

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Asking for my understanding, how badly it looks in comparison when we use the super class methods OOTB?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For my understanding as well.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please see below the details.
Without the change using the below.

this.logger.error(`Error uploading file ${remoteFilePath}.`);
this.logger.error(error);

Results
image

Using the below.

this.logger.error(`Error uploading file ${remoteFilePath}.`, error);

Results
image

Using the PR code.

this.logger.error(`Error uploading file ${remoteFilePath}.`, error);

image

this.logger.error(`Error uploading file ${remoteFilePath}.`, error, "SOME CONTEXT");

image

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To be honest the parseJSONError was a quick implementation from the past to try to print errors and causes recursively.
It can be done in a better way but it is the method that we have right now.

try {
this.logger.log(`Uploading ${remoteFilePath}`);
client = await this.getClient();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

Copy link

sonarqubecloud bot commented Nov 6, 2024

Copy link

github-actions bot commented Nov 6, 2024

Backend Unit Tests Coverage Report

Totals Coverage
Statements: 22.3% ( 3692 / 16556 )
Methods: 10.32% ( 212 / 2055 )
Lines: 25.6% ( 3202 / 12507 )
Branches: 13.94% ( 278 / 1994 )

Copy link

github-actions bot commented Nov 6, 2024

E2E Workflow Workers Coverage Report

Totals Coverage
Statements: 65.43% ( 583 / 891 )
Methods: 59.26% ( 64 / 108 )
Lines: 68.54% ( 464 / 677 )
Branches: 51.89% ( 55 / 106 )

Copy link

github-actions bot commented Nov 6, 2024

E2E Queue Consumers Coverage Report

Totals Coverage
Statements: 85.92% ( 1220 / 1420 )
Methods: 87.86% ( 123 / 140 )
Lines: 86.83% ( 1035 / 1192 )
Branches: 70.45% ( 62 / 88 )

Copy link

github-actions bot commented Nov 6, 2024

E2E SIMS API Coverage Report

Totals Coverage
Statements: 66.01% ( 5571 / 8439 )
Methods: 63.3% ( 683 / 1079 )
Lines: 70.12% ( 4401 / 6276 )
Branches: 44.93% ( 487 / 1084 )

Copy link
Collaborator

@sh16011993 sh16011993 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work @andrewsignori-aot 👍 Thanks for explaining the PR comment.

Copy link
Collaborator

@dheepak-aot dheepak-aot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for making the changes and the log screenshots. Looks good. 👍

@andrewsignori-aot andrewsignori-aot merged commit ba81ad5 into release/v1.15.0 Nov 6, 2024
20 checks passed
@andrewsignori-aot andrewsignori-aot deleted the feature/sftp-archive-improvements branch November 6, 2024 22:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Ad-hoc Integration Prod Required Strongly recommended for production. Queue Consumers SIMS-Api SIMS-Api
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants