Files
notifications-admin/application.py
Ben Thorner d752b0b83a 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]: 74a958de00/notifications_python_client/base.py (L118)
2021-12-31 12:04:35 +00:00

24 lines
642 B
Python

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
sentry_sdk.init(
dsn=os.environ['SENTRY_DSN'],
integrations=[FlaskIntegration()],
environment=os.environ['NOTIFY_ENVIRONMENT'],
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')
create_app(application)