From d752b0b83a942b7ff01e0dbda7856f5d3133a42e Mon Sep 17 00:00:00 2001 From: Ben Thorner Date: Fri, 31 Dec 2021 12:04:35 +0000 Subject: [PATCH] Silence errors from Python Client Otherwise we start spamming Sentry with every 404 error log. Even if the erorr is a 5xx, it depends on how we handle it in the calling code as to whether we would want to consider it an error. I didn't spot this in initial testing on Preview because the 404s in Preview are only triggered due to the functional tests, which only run when we're deploying something. Arguably we shouldn't be logging at error level in our Python Client, since we're also raising an exception [1]. But changing that would be a can of worms as it's not an internal-only library. [1]: https://github.com/alphagov/notifications-python-client/blob/74a958de00d39571101996c8483869ba43068006/notifications_python_client/base.py#L118 --- application.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/application.py b/application.py index 6fb8039eb..6f383dcbb 100644 --- a/application.py +++ b/application.py @@ -3,6 +3,7 @@ import os import sentry_sdk from flask import Flask from sentry_sdk.integrations.flask import FlaskIntegration +from sentry_sdk.integrations import logging from app import create_app @@ -13,7 +14,9 @@ sentry_sdk.init( attach_stacktrace=True, traces_sample_rate=0.00005 # avoid exceeding rate limits in Production ) + sentry_sdk.set_level('error') # only record error logs or exceptions +logging.ignore_logger('notifications_python_client.*') # ignore logs about 404s, etc. application = Flask('app')