Skip to content

Commit

Permalink
filter out AnalysisError related messages (#735)
Browse files Browse the repository at this point in the history
  • Loading branch information
burnout87 authored Jan 28, 2025
1 parent 230dc27 commit df50ce2
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion cdci_data_analysis/flask_app/sentry.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
from __future__ import annotations

import logging
import sentry_sdk
from sentry_sdk.types import Hint, Event
import os

# logger = logging.getLogger(__name__)
Expand Down Expand Up @@ -41,7 +44,8 @@ def have_sentry(self):
traces_sample_rate=0.1,
debug=False,
max_breadcrumbs=10,
environment=getattr(self.app.config.get('conf'), 'sentry_environment', 'production')
environment=getattr(self.app.config.get('conf'), 'sentry_environment', 'production'),
before_send=self.filter_event
)
except Exception as e:
self.logger.warning("can not setup sentry with URL %s due to %s", self.sentry_url, e)
Expand All @@ -56,4 +60,14 @@ def capture_message(self, message: str):
else:
self.logger.warning("sentry not used, dropping %s", message)

@staticmethod
def filter_event(event: Event, hint: Hint) -> Event | None:
message = event.get("message", None)
if message is not None:
if "AnalysisError" in message:
return None

return event


sentry = Sentry()

0 comments on commit df50ce2

Please sign in to comment.