Draft: fix: Remove non workflow breaking checkpointing error from Sentry Logs
What does this merge request do and why?
Adds filtering in the before_send field for Sentry monitoring for non workflow breaking JSON decode errors in http_client.
These seem to be related to errors from Gitlab.com API when it returns a 500 error when using the /checkpoint endpoint. This does not fail workflows as the response from checkpointing is not considered.
This MR introduces filtering logic in sentry_error_tracking.py for logged errors with the following attributes:
- Originating from
_parse_response - Is a
JSONDecodeError - Contains
/checkpointsin the path
Relates to #1009 (closed)
How to set up and validate locally
Ensure Sentry logging is enabled locally:
SENTRY_ERROR_TRACKING_ENABLED=true
SENTRY_DSN="http://test123"
Then add logging at these two points:
test_sentry_filtering.patch
diff --git a/duo_workflow_service/tracking/sentry_error_tracking.py b/duo_workflow_service/tracking/sentry_error_tracking.py
index 6d8ba662..21ac5963 100644
--- a/duo_workflow_service/tracking/sentry_error_tracking.py
+++ b/duo_workflow_service/tracking/sentry_error_tracking.py
@@ -75,6 +75,7 @@ def filter_checkpoint_errors(event: Event, hint: Hint) -> Optional[Event]:
extra = event.get("extra", {})
path = extra.get("path", "")
if is_json and is_from_http_client and "/checkpoints" in path: # type: ignore[operator]
+ log.info(f"Filtered from Sentry")
return None
-
+ log.info(f"Not filtered from Sentry")
return event
Merge request checklist
-
Tests added for new functionality. If not, please raise an issue to follow up. -
Documentation added/updated, if needed.
Edited by Tim Morriss