Skip to content

Simple Project demonstrates failure of logger.exception with new sentry sdk

License

Notifications You must be signed in to change notification settings

darahsten/sentry_nologger_demo

Repository files navigation

New Sentry SDK Logger.exception failure Demo

A project to demo failure of logger.exception to sent to sentry in new sentry sdk

Built with Cookiecutter Django Black code style

Introduction

The new sentry sdk (DSN) introduces some incompatibilities with raven. Documentation on how to upgrade to the new sentry sdk from using the old raven client is lacking for django projects.

I wanted to upgrade and discovered along the way that logger.exception(repr(e)) no longer sends any errors to sentry when using the new dsn and default configuration for django

See more here https://stackoverflow.com/questions/57274935/configuring-sentry-handler-for-django-with-new-sentry-sdk-without-raven/57294650#57294650

This is a simple project to demo that behavior in response to the comments.

SETUP

Configured using sqlite (no need for postgres).

setup a virtualenv mkvirtualenv sentry_nologger_demo workon on sentry_nologger_demo

pip install -r requirements.txt

python manage.py runserver --settings=config.settings

Ensure that you have a .env file with environment variable DJANGO_SENTRY_DSN=project_sentry_dsn in the new format i.e. without the secret key

To test navigate to localhost:8000/sentry-debug/ >>>> Tells you, you are logging to sentry correctly. Will throwup an exception in template

Navigate to localhost:8000/sentry-logs-error/ >>>> using capture exception to log the error, You should see this in sentry

Navigate to localhost:8000/sentry-nologs-error/ >>>>>> trying logger.exception, never logs anything to sentry. This will only appear in console

All the demo pages are in config.urls FYI. If I made a mistake in the setup please let me know.

About

Simple Project demonstrates failure of logger.exception with new sentry sdk

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published