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

Blokh
Hey guys, I’ve got a huge CSV ( around 10 GB ) that needs to be processed hourly Do you guys have any suggestions what is the best prac...
New
kszambelanczyk
Hello! Could someone please give me a help/sample code, how to delete a file from s3 using waffle/waffle_ecto from Phoenix app. I creat...
New
RemyXRenard
I’m seeing that a list inside a Kino.DataTable will be interpreted as a charlist, even if the Kino.configure() is set to charlists: :as_l...
New
matt-savvy
Anyone here using Honeybadger? My Honeybadger account is being overwhelmed with noise from some bots. Seeing a lot of Bandit.HTTPError...
New
samoloth
Hi, I’ve just set up an application with ash_authentication. There is only magic link strategy for now, so there is no confirmation add o...
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
FlyingNoodle
If a change or preparation module uses Ash.Changeset.get_argument/2 or Ash.Query.get_argument/2 (or any of the other get_argument functio...
New

Other Trending Topics Top

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
mcass19
ExRatatui lets you cook up rich terminal UIs in Elixir, powered by Rust’s ratatui via Rustler NIFs. Build interactive terminal applicatio...
New
Damirados
Hello everyone. After busy few months I am happy to announce v0.1.0 of Emerge & Solve. They are GUI (Emerge) and State management (S...
New
netoum
Corex is an accessible, unstyled UI component library for Phoenix that integrates Zag.js state machines using Vanilla JavaScript and Live...
New
wintermeyer
There are three potential reasons for members of this forum to have a look at https://vutuv.de You are tired or annoyed of LinkedIn. Yo...
New

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews