-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #551 from MITLibraries/TIMX-258-graceful-record-skip
Skip errors during harvest and report to Sentry
- Loading branch information
Showing
12 changed files
with
1,001 additions
and
569 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -107,5 +107,6 @@ tmp/* | |
out.xml | ||
.DS_Store | ||
.vscode | ||
.idea | ||
|
||
output/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
"""exceptions.py module.""" | ||
|
||
|
||
class MaxAllowedErrorsReached(Exception): | ||
"""Thrown when maximum numbers of errors reached during GetRecords harvest.""" | ||
|
||
pass |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
"""utils.py module.""" | ||
|
||
import sentry_sdk | ||
|
||
|
||
def send_sentry_message( | ||
message: str, | ||
scopes: dict | None = None, | ||
level: str = "warning", | ||
): | ||
"""Send message directly to Sentry. | ||
This allows both reporting information without raising an Exception, and optionally | ||
including additional information in the sent Sentry message via "scopes". | ||
Args: | ||
message: Primary message string for Sentry message. | ||
scopes: Dictionary of key/value pairs which become additional information in the | ||
Sentry message. | ||
level: String of [info,debug,warning,error] that will set the severity of the | ||
Sentry message. | ||
""" | ||
with sentry_sdk.push_scope() as scope: | ||
if scopes: | ||
for scope_key, scope_value in scopes.items(): | ||
scope.set_extra(scope_key, scope_value) | ||
send_receipt = sentry_sdk.capture_message(message, level=level) | ||
return send_receipt |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.