gen_state_machine
gen_state_machine copied to clipboard
Crashes aren't reported to Sentry
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 GenStateMachine
s 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)