mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-02-25 04:40:58 -05:00
This makes a couple of changes:
- Most importantly, it wraps the setup code in a conditional so that
developers don't need to have a DSN set to start the app locally.
- Secondly, it removes the redundant call to "set_level". Originally
I thought the integration was sending info/warning events, but this
isn't the case [1] and even if it was, "set_level" affects the level
of custom events [2], not the level they are dispatched at.
[1]: 4c09f3203d/sentry_sdk/integrations/logging.py (L56)
[2]: https://docs.sentry.io/platforms/python/guides/logging/usage/set-level/
25 lines
714 B
Python
25 lines
714 B
Python
import os
|
|
|
|
import sentry_sdk
|
|
from flask import Flask
|
|
from sentry_sdk.integrations.flask import FlaskIntegration
|
|
from sentry_sdk.integrations.redis import RedisIntegration
|
|
from sentry_sdk.integrations import logging
|
|
|
|
from app import create_app
|
|
|
|
if 'SENTRY_DSN' in os.environ:
|
|
sentry_sdk.init(
|
|
dsn=os.environ['SENTRY_DSN'],
|
|
integrations=[FlaskIntegration(), RedisIntegration()],
|
|
environment=os.environ['NOTIFY_ENVIRONMENT'],
|
|
attach_stacktrace=True,
|
|
traces_sample_rate=0.00005 # avoid exceeding rate limits in Production
|
|
)
|
|
|
|
logging.ignore_logger('notifications_python_client.*') # ignore logs about 404s, etc.
|
|
|
|
application = Flask('app')
|
|
|
|
create_app(application)
|