I've taken over a project that uses python and flask (and I'm new to python/flask too!). I'd like to add Sentry to it to capture any errors/exceptions that happen. To add to the complexity the project is split into multiple docker containers that link to each other. I'm trying at first to get the main "frontend" container to start logging errors to Sentry.
I've read the documentation but it's only served to confuse me even more.
For example (from the frontend.py file):
app = WebServer(logger, environment)
sentry = Sentry(app, logging=True, level=logging.INFO)
This is in the frontend part of the app. From what I understand this should allow Sentry to capture any exceptions and send it off, but nothing happens (I did a simple division by zero to force an exception).
I'm sure I'm probably missing something but I'm just confused by the documentation.
For example, in the logging option (I've been considering maybe using this option instead), it talks about setting up a client manually. What client is it talking about?
I've set up Sentry to work in a PHP Laravel app before with no problems at all, and it was very very easy to do. This python way is confusing the hell out of me.
So this is what I ended up doing:
from raven import Client
from raven.conf import setup_logging
from raven.handlers.logging import SentryHandler
sentry_dsn = 'MY DSN FROM SENTRY'
sentry_client = Client(dsn=sentry_dsn, site='MYAPP')
handler = SentryHandler(sentry_client)
handler.setLevel(logging.ERROR)
setup_loggin(handler)
So setting up this way I am now finding that any where in my app I use the logger, sentry will pick it up and send it off.
Also so that I know which section it's coming from, I create a logger with a meaningful name: eg logger = logging.getLogger('meaningfulname')
then Sentry will display 'meaningfulname' in its results.