avoid sending MethodNotAllowed to sentry (#1888)

Co-authored-by: burnettk <burnettk@users.noreply.github.com>
This commit is contained in:
Kevin Burnett 2024-07-08 15:49:17 +00:00 committed by GitHub
parent 429692091a
commit e962a0380b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 5 additions and 0 deletions

View File

@ -258,6 +258,8 @@ def should_notify_sentry(exception: Exception) -> bool:
return False
# like a 404, 405 Method Not Allowed: The method is not allowed for the requested URL
# it doesn't seem to work to exclude this here. i guess it happens before it gets to our app?
# excluded via before_send in configure_sentry
if isinstance(exception, MethodNotAllowed):
return False

View File

@ -8,6 +8,7 @@ import flask.wrappers
import sentry_sdk
from prometheus_flask_exporter import ConnexionPrometheusMetrics # type: ignore
from sentry_sdk.integrations.flask import FlaskIntegration
from werkzeug.exceptions import MethodNotAllowed
from werkzeug.exceptions import NotFound
@ -60,6 +61,8 @@ def configure_sentry(app: flask.app.Flask) -> None:
# NotFound is mostly from web crawlers
if isinstance(exc_value, NotFound):
return None
if isinstance(exc_value, MethodNotAllowed):
return None
return event
sentry_errors_sample_rate = app.config.get("SPIFFWORKFLOW_BACKEND_SENTRY_ERRORS_SAMPLE_RATE")