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

CV2-4790 fix broken error log due to missing file, surface s3 errors to sentry #429

Merged
merged 1 commit into from
Jul 8, 2024

Conversation

DGaffney
Copy link
Contributor

@DGaffney DGaffney commented Jul 5, 2024

Description

Right now we hit an error where files isn't defined when we try to log the needle error to sentry, and we don't log failures to download the files from S3 directly to sentry. Let's resolve that to make easier the job of surfacing whatever the needle error is.

Reference: CV2-4790

How has this been tested?

No tests on this yet - may need to change a unit test or two.

Have you considered secure coding practices when writing this code?

None

@@ -32,6 +34,7 @@ def download_file_from_s3(bucket: str, filename: str, local_path: str):
s3_client.download_file(bucket, tmk_file, local_path)
app.logger.info(f'Successfully downloaded file {tmk_file} from S3 bucket.')
except Exception as e:
ErrorLog.notify(e, {"bucket": bucket, "filename": filename, "local_path": local_path, "tmk_file": tmk_file})
Copy link

Choose a reason for hiding this comment

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

Line too long (116/100)

Copy link

codeclimate bot commented Jul 5, 2024

Code Climate has analyzed commit 496c68f and detected 1 issue on this pull request.

Here's the issue category breakdown:

Category Count
Style 1

The test coverage on the diff in this pull request is 33.3% (50% is the threshold).

This pull request will bring the total coverage in the repository to 80.8% (0.0% change).

View more on Code Climate.

@@ -3,6 +3,8 @@

from flask import current_app as app

from app.main.lib.error_log import ErrorLog
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm surprised the ErrorLog is needed to get errors to sentry, normally it already picks up on anything sent to python error output, so I'd think app.logger.error() would work?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Maybe its a difference in configuration but I believe Sentry only surfaces raised actual errors and not log messages?

Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe. Originally I added a bunch of explicit sentry error dispatch, then removed most of it because I was seeing dupes. https://stackoverflow.com/questions/73456044/why-does-sentry-log-errors-caught-in-except-block

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hrm - well, I'll do the same then if I see the problem manifesting here? lol

@DGaffney DGaffney requested a review from skyemeedan July 5, 2024 20:42
@DGaffney DGaffney merged commit 20cb5f2 into develop Jul 8, 2024
4 checks passed
@DGaffney DGaffney deleted the cv2-4790-needle-logging branch July 8, 2024 14:36
DGaffney added a commit that referenced this pull request Jul 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants