Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Sentry as a way not to be afraid by Irina Grechikhina

Pycon ZA
October 11, 2019

Sentry as a way not to be afraid by Irina Grechikhina

Sentry is an open-source error tracking software. It allows you to know exactly what's going on with your web application in real-time and get exact and detailed reports about occurred errors. Lot's of web developers used to rely only on app logs and generic monitoring software, but it's not enough. Multiple production servers, overwhelmed logging, lack of information about request content in case of error hinders problem investigation and produces permanent developer fear of changes. Sentry could ease the whole process and make you: stay calm during deployment, be sure your application works properly, solve problems before users report about it.

During my talk, I will compare Sentry to ordinary logging, show how to use Sentry, explain how to read Sentry reports and demonstrate that its deployment is very easy. The whole demo will be done using Sentry hosted on my laptop. I will describe the problems I have faced up during sentry.io usage and explain why I prefer self-hosting. Also, I will share a link to my Github with docker-compose and ansible files to deploy your self-hosted Sentry, run through the whole idea and demonstrate that everything is clear and easy. Then I will show how to adjust the first project in Sentry and connect it to a working application in both backend and frontend parts. For each backend and frontend cases, there will be its separate part with examples when Sentry is useful and cannot be replaced by other tools and recommendations on how to make Sentry as effective as possible.

My talk will be useful for web developers of any level who wants to ease the process of problem investigation and finds application logs not handy.

Pycon ZA

October 11, 2019
Tweet

More Decks by Pycon ZA

Other Decks in Programming

Transcript

  1. Do you know about Sentry? Do you know you can

    use it for free? Do you know you can self-host it? Do you use Sentry?
  2. Disadvantages of logs: • several machines + different environments •

    noisy (“expectable errors” along with important ones) In the end: • no one looks through logs for a long time • rare mistakes are lost and not everything settles in the logs: query string VS body
  3. No, Sentry won’t bombard you with notifications: • only first

    time and resolved errors will push notifications • notification frequency is configurable and you can integrate with Slack or Telegram
  4. To avoid another “dead logs” instance: • from time to

    time fix even non-critical bugs • set "resolved” status automatically in a week after the first error occurrence
  5. Sentry allows: • to be notified about errors instantly as

    soon as they occur • not to crawl through the logs with tail+grep • not to search necessary logs on different servers • not to miss an important new error or regression
  6. Some Sentry use cases: • monitor problems in third-party services

    • monitor known errors • don't be afraid to do refactoring • track obsolete clients
  7. Divide errors into groups: def before_send(event, hint): if hint and

    hasattr(hint['log_record'], 'fingerprint'): event['fingerprint'] = hint['log_record'].fingerprint return event sentry_sdk.init( dsn='https://<key>@sentry.io/<project>', integrations=[FlaskIntegration()], before_send=before_send ) logger.error(‘Special users! uid=%s', user_id, extra={'fingerprint': [‘oh-users', user_id]})
  8. Gather user feedback: Sentry.init({ dsn: 'http://[email protected]:8080/2', beforeSend(event, hint) { //

    Check if it is an exception, and if so, show the report dialog if (event.exception) { Sentry.showReportDialog({ eventId: event.event_id }); } return event; } });
  9. use Sentry = know what's going on with your project

    + be sure it works + don't be afraid to make changes integrate Sentry in the development phase