evalphobia / logrus_sentry

sentry hook for logrus
MIT License
194 stars 78 forks source link

Fix default stracktrace being reported if the root Cause doesn't implement the stacktrace interfaces #38

Closed Phlamethrower closed 7 years ago

Phlamethrower commented 7 years ago

This fixes a bug where stack traces which are attached to errors will be ignored.

findStackTrace is meant to look through the entire chain of errors (via the Causer interface), searching for the last stack trace in the chain (which should correspond to the point that's closest to the origin of the error). But because err := errors.Cause(err) has already been performed, the error that's passed to findStackTrace will always be the last error in the chain, and that error might not be the one that provides the stack trace. E.g. if you use errors.Wrap() to wrap a JSON unmarshal error then the stacktrace won't be found. The code will then fall back to generating a new stack trace (corresponding to the call to the log function), potentially losing important context about the true location of the error.

coveralls commented 7 years ago

Coverage Status

Coverage decreased (-0.3%) to 83.046% when pulling 8f011ee3b4ee0e1b257ecbfeb71883b83c479d7a on Exient:fix_find_earliest_stacktrace into 162fd93cca6f0b1170f1b12c980a004744297f13 on evalphobia:master.

evalphobia commented 7 years ago

Thank you! 🍺

Note: https://github.com/evalphobia/logrus_sentry/releases/tag/v0.2.11