Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Erros: Como eles vivem, se alimentam e se reproduzem? - Augusto Pascutti

68 views

Published on

Augusto Pascutti - Developer, Creditas

Para o quê eles servem e como usá-los de forma mais eficiente, seja através de integrações com outras ferramentas ou só seguindo receitas de como as mensagens de erro devem ser geradas e compostas.

Apresentado no InterCon 2018: https://eventos.imasters.com.br/intercon

Published in: Software
  • Be the first to comment

  • Be the first to like this

Erros: Como eles vivem, se alimentam e se reproduzem? - Augusto Pascutti

  1. 1. ERRORS How cognitive bias prevent you from using them http://bit.ly/gugu-talk-errors
  2. 2. “‘Error’ is a bad name for good data. Feathers, Michael. 2018: Tweet
  3. 3. Availability heuristic We expect things to work, ignoring the usefulness of error A biased prediction, due to the tendency to focus on the most salient and emotionally-charged outcome. Gabriel, P. Richard: The Rise of Worse Is Better
  4. 4. How I learned to program
  5. 5. How I program after 10 years
  6. 6. “Good judgement is the result of experience, experience is the result of bad judgement. Fred Brooks
  7. 7. Treat errors and logs the same Assert, measure and don’t forget to learn!
  8. 8. Log messages have 10 parts
  9. 9. 1. Messages ● Choose one: ○ What happened? ○ What didn’t happen? ○ What should be done? ● DDD (the shit out of) them: ○ Make usage of ubiquitous language ○ The same error should always produce the same message (allowing to group them) Not easy to make them good, impossible if you don’t start using them
  10. 10. 2. Contexts ● Important details: ○ When it happened? ○ Where it happened? ■ Application name ■ Environment ■ Hostname ○ Severity ○ Facility ● Details to aid debug: ○ User information ○ Stack trace ○ HTTP call being made ○ What file/line generated it? ○ Request ID ● Usually follow a filterable pattern The devil is on the details
  11. 11. Day-to-day vocabulary
  12. 12. Error Emergency, Alert, Critical or Error A database drop, an update without “where”, hardware failure, resource stealing, an attack or an old lady scraping metal to sell… shit happens. When they happen, we usually have contingency. But there is a limit to it, so we act quickly on those - so they don’t become defects. 2001. Lonvick, C.: The BSD syslog Protocol (IETF RFC 3164)
  13. 13. Defect What customers should never face We never want end-users seeing errors. We know them as bugs, but using a more specific term for when end-users are affected speeds communication and resolution. 2008. Pryce, Nat: Throw Defect
  14. 14. Warning Notice, Info and Debugs Fixing bugs is also known as debugging, logs aid on that. Remember those `var_dump` calls? Make them log messages and use the severity based on the likelihood of defects happening because of them. 2001. Lonvick, C.: The BSD syslog Protocol (IETF RFC 3164)
  15. 15. Is this message Good or Bad?
  16. 16. Database error
  17. 17. @augustohp not found
  18. 18. Missing DB_DSN environment variable
  19. 19. 404: Page not found
  20. 20. Where can you find good error messages? ● Database error messages, care for how variable they are ● HTTP errors are few and precious, not a bingo ● PHP errors are very informative, care for variables as well
  21. 21. When to use variable messages? Be mindful of who they are for
  22. 22. 2002. Spolsky, Joel: The Law of Leaky Abstractions Hardware OS I/O Language Framework App Abstraction level
  23. 23. 2002. Spolsky, Joel: The Law of Leaky Abstractions Hardware OS I/O Language Framework App Errors “leak” from lower levels
  24. 24. What if alerts are used?
  25. 25. Cry wolf You must never filter which error is relevant Anthropic bias is when evidence is biased by “observation selection effects”. You don’t want to base your assumptions over someone’s observation. 2012. Bostrom, Nick: Anthropic Bias - Observation Selection Effects in Science and Philosophy
  26. 26. Alert over frequency Monitorama EU 2013 - Lindsay Holmwood: Psychology of alert design
  27. 27. “Abstractions save us time working, not learning. Joel Spolsky
  28. 28. The PHP cookbook for Errors Dirty tricks for the day to day 2014. Pascutti, Augusto: Logs - O que eles comem, onde vivem e como se reproduzem
  29. 29. PHP Configuration
  30. 30. Development You want to see every nasty error ; php.ini display_errors = On error_reporting = -1 log_errors = On error_log = /var/log/php_error.log
  31. 31. Production Make them sexy, and log them ; php.ini display_errors = Off error_reporting = -1 log_errors = On error_log = /var/log/php_error.log
  32. 32. Chain exceptions
  33. 33. Create 2 base exceptions
  34. 34. 2008. Pryce, Nat: Generic Throws
  35. 35. Exception ideas
  36. 36. 2008. Pryce, Nat: Throw Defect
  37. 37. Exceptions are for exceptional cases C2 Wiki: Don’t use Exceptions For Flow Control
  38. 38. Use monolog (PSR-3)
  39. 39. Aggregate using Syslog 2001. Lonvick, C.: The BSD syslog Protocol (IETF RFC 3164)
  40. 40. “I would advise students to pay more attention to the fundamental ideas rather than latest technology. The technology will be out-of-date before they graduate. Fundamental ideas never get out of date. David Lorge Parnas
  41. 41. Conclusions ● Errors are not problems ● Treat them like logs ● Log eases debugging
  42. 42. Can I help you make more mistakes? Questions? Suggestions?! Beer time?
  43. 43. Credits ● Fonts in use are Ubuntu (Ubuntu) and Gentium Basic (Sil International) ● Theme is based on Solarized color-scheme by Ethan Schoonover

×