tanweerdev

tanweerdev

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

Showing Posts 1 to 7

josevalim

josevalim

Creator of Elixir

@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
tanweerdev

tanweerdev OP

Environment:

Elixir version (elixir -v):
Elixir 1.10.2 (compiled with Erlang/OTP 21)
Erlang/OTP version (erl):
Erlang/OTP 21
Sentry version (mix deps):
8.0.2
Operating system:
Erlang/OTP 21
Is this an umbrella application?:
yes
Release type (Distillery, mix release, Mix, etc.):
iex -S mix phx.server

Here is issue submitted for more details

tanweerdev

tanweerdev OP

This did not help sentry capture error msgs. (I have before_send hook to confirm where I print the event). The only thing which worked is manually capturing it

Task.start(fn ->
  try do
    MyModule.function()
  rescue
    exception ->
      Sentry.capture_exception(exception, [stacktrace: System.stacktrace(), extra: %{extra: %{extra_information: "my extra information"}}])
  end
end)
tanweerdev

tanweerdev OP

Thanks @josevalim @chulkilee for your kind replies. is there any way, I can make this Task.start + try/capture a utility function and call it whenever I needed to use Task.start and it will capture errors…

chulkilee

chulkilee

I confirm I’m getting sentry via Task.start in this case:

  1. Create new project
  2. Add sentry dep
  3. 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"
  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.

josevalim

josevalim

Creator of Elixir

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. :slight_smile:

— All posts loaded —

Where Next? Top

Trending in Questions Top

katta
I having some trouble figuring out if I have set myself too strict of standards for my production server. Currently I can handle 75% of r...
New
nseaSeb
Hello, I know there is an approach for handling lists that allows for optimized traversal, but I can’t recall the specific method (somet...
New
brecabral
Documentation While reading the Scoped Routes section, I noticed that the documentation currently refers to a problem without explainin...
New
kpanic
Hi everyone, I am toying with the idea of building a “match maker” for giving personal help to people that wants to start coding. I sta...
New
velrest
So my question is quite simple and i have found no conclusive answer on forum, google or AI. Should we use :erlang.float for Integer to ...
New
asweet-confluent
I recently noticed that Elixir’s Logger defaults its primary log level to :debug when no :logger, :level application configuration is pre...
New
apz
I’m new to elixir and just tried to install the elixirLS extension for VScode(ium) and it is throwing some errors that I would like help ...
New

Other Trending Topics Top

GenericJam
Edit: 2026 May 15 - This post is archived. Mob is alive!! Main docs: mob v0.7.11 — Documentation A bit of explanation for the slightly c...
New
JesseHerrick
Hey, I’m Jesse and I’m the main contributor behind Dexter, a full-featured, lightning-fast Elixir LSP optimized for large codebases. It s...
New
mudasobwa
I am happy to introduce the very α version of the new programming language compiled to BEAM. Welcome Cure. It has literally three kille...
New
garrison
Hobbes is a low-level distributed database for the Elixir programming language. Hobbes provides a simple, safe, and scalable storage lay...
New
mhanberg
Hi everyone! The first release candidate for the Expert language server project is now available! We’ve published a press release detai...
New
mcass19
ExRatatui lets you cook up rich terminal UIs in Elixir, powered by Rust’s ratatui via Rustler NIFs. Build interactive terminal applicatio...
New

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews