tanweerdev
Sentry not capturing crashes inside Task.start function
I am using sentry version 8.0.2 and its reporting errors perfectly for normal cases. But for the functions which I execute via Task.start it wont report errors. inside my phoenix endpoint file I have
use Sentry.PlugCapture
...
plug Sentry.PlugContext
in my config I also have
config :logger,
+ backends: [:console, Sentry.LoggerBackend]
Configuration seems correct but I am not able to capture events. Maybe I am missing something… Any help or guidance is welcome. Thanks
Marked As Solved
chulkilee
Probably this issue?
Also Liked
josevalim
@tanweerdev what is your Elixir version? Sentry expects a particular metadata to be available for logging that was only recently added to Elixir.
You can also ask Sentry to capture all log messages. Here is what I do:
config :logger, Sentry.LoggerBackend,
level: :warn,
excluded_domains: [:cowboy],
capture_log_messages: true
josevalim
Note you likely don’t want to configure this in your config/config.exs, as Sentry.LoggerBackend may be loaded even before it is compiled. This will definitely be the case in umbrella projects if only part of them depend on Sentry. Instead, call Logger.add_backend(Sentry.LoggerBackend) in your application start/2 callback. ![]()
chulkilee
I confirm I’m getting sentry via Task.start in this case:
- Create new project
- Add sentry dep
- Add sentry logger backend (no other configuration)
config :logger,
backends: [:console, Sentry.LoggerBackend]
config :sentry, dsn: "http://a:b@127.0.0.1:8000/1"
- Add following to a controller function
Task.start(fn ->
MyModule.function()
end)
With or without phoenix integration, it sends a request - but it does not print sentry log.
I ran dummy server with python3 -m http.server 8000 --bind 127.0.0.1 to see whether my phoenix app actually sends a request.








