gen_state_machine icon indicating copy to clipboard operation
gen_state_machine copied to clipboard

Crashes aren't reported to Sentry

Open al2o3cr opened this issue 4 years ago • 0 comments

The messages generated by GenStateMachine.Translator don't have the metadata that modern versions of Sentry's reporter (8.0+) is expecting, so they aren't captured at all.

This caused some serious head-scratching at work, because we had GenStateMachines that were crashing but not reporting to Sentry 😱

The issue appears to be that Sentry expects a crash_reason key in the metadata:

https://github.com/getsentry/sentry-elixir/blob/121464782e522d59a26ffd523fffb84eb746a357/lib/sentry/logger_backend.ex#L111

This is set for GenServer and GenEvent reports by code in stdlib's Logger.Translator:

https://github.com/elixir-lang/elixir/blob/d30c5c0185607f08797441ab8af12636ad8dbd7e/lib/logger/lib/logger/translator.ex#L196-L201

I've bent the code from Logger.Translator into roughly the right shape in our application; if it doesn't cause any trouble in production I'll try to turn it into a PR (or add it here; it's possible to substitute the translator at application-boot time)

al2o3cr avatar Feb 08 '21 18:02 al2o3cr