evalphobia / logrus_sentry

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

Send errors to sentry as an Exception #12

Closed belak closed 8 years ago

belak commented 8 years ago

Logrus has Entry.WithError and an ErrorKey which provides a common place to store errors for logging. This pulls errors out and sends them as an Exception if stack traces are enabled.

It also sets the culprit to the error message (since it's the least intrusive), though my personal preference would be to take the message in the logrus entry, store that as the culprit and place the error message in the outgoing packet message. This still misses a little something, because the culprit from the Stacktrace isn't used, but it doesn't ignore the original message and puts the error message in a more useful location.

coveralls commented 8 years ago

Coverage Status

Coverage decreased (-0.7%) to 54.124% when pulling 66a2bff03aa1d24eeae0707c27ba588524662e70 on belak:belak/capture-exception into 339ff6c84fac211e3246e0dd5aa9f6ea3abf4295 on evalphobia:master.

belak commented 8 years ago

This is based on some code we used internally (originally based on this code), copied here: https://gist.github.com/belak/3c205bc30a12cef954f57b542abcfb54

belak commented 8 years ago

I just realized that this won't work quite yet because all the error values are pulled out and converted to strings.

EDIT: This should be fixed.

coveralls commented 8 years ago

Coverage Status

Coverage decreased (-0.7%) to 54.124% when pulling ae30acd7da0d02567fa252ea347389cb172e2a47 on belak:belak/capture-exception into 339ff6c84fac211e3246e0dd5aa9f6ea3abf4295 on evalphobia:master.

coveralls commented 8 years ago

Coverage Status

Coverage increased (+0.2%) to 55.0% when pulling 60d9af73f70d161265759c6526e2b2998992bf2d on belak:belak/capture-exception into 339ff6c84fac211e3246e0dd5aa9f6ea3abf4295 on evalphobia:master.

evalphobia commented 8 years ago

@belak Thanks! I'll check this.

evalphobia commented 8 years ago

This works good! 👍

sentry01

@belak Would you rebase&squash all commits into one? After that I'll merge this 🙆

belak commented 8 years ago

Is it a problem that the tags were removed? I'm not 100% sure why it would do that.

coveralls commented 8 years ago

Coverage Status

Coverage increased (+0.2%) to 55.0% when pulling 371a6e12f682dd5e21f9a1167c915a7c4e91e08b on belak:belak/capture-exception into 339ff6c84fac211e3246e0dd5aa9f6ea3abf4295 on evalphobia:master.

coveralls commented 8 years ago

Coverage Status

Coverage increased (+0.2%) to 55.0% when pulling 371a6e12f682dd5e21f9a1167c915a7c4e91e08b on belak:belak/capture-exception into 339ff6c84fac211e3246e0dd5aa9f6ea3abf4295 on evalphobia:master.

evalphobia commented 8 years ago

Did you reproduce this tags problem on your environment? I don't use this feature actually, so I don't care about it. But someone might use tag feature. If the problem reproduced on others environment, I'll send inquiry to Sentry staff.