tanweerdev

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

chulkilee

Probably this issue?

Also Liked

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

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.

Where Next?

Popular in Questions Top

vonH
In asking this question I am more interested about the expressiveness of the language itself and less concerned about the availability of...
New
bsollish-terakeet
Credo is smart enough to check for (something like) this: assert length(the_list) == 0 with this response: Checking if an enum is empt...
New
JorisKok
I have a server on AWS, and was running a load test using artillery. When looking at the Phoenix dashboard I see the Ports going to 100% ...
New
itssasanka
Hi all, Trying to get some more clarity over utc_datetime and naive_datetime for Ecto: https://hexdocs.pm/ecto/Ecto.Schema.html#module-...
New
aalberti333
As the title describes, I’m trying to run Enum.map() over a list of key/value pairs, where the value is a map. My data looks like this: ...
New
myronmarston
The Elixir Typespec docs show the following syntax for keyword lists in typespecs: # ... | [key: type] # keyword lis...
New
johnnyicon
Hi all, I've just started learning Elixir and Phoenix Framework, so please pardon my n00bness at this stage. I'm trying to use Postg...
New
baxterw3b
Hi guys, i’m new in the Elixir world, and i have to say, that i love it! i’m having some problem to understand anonymous functions with ...
New
belgoros
I’m not a pro in using Regex and can’t figure out why the following behaviour happens, especially if we take into account the difference ...
New
jc00ke
Expanding on this topic: https://forum.elixirforum.net/t/map-typespec-question/19217 Let’s say I have a map with required and optional k...
New

Other popular topics Top

Brian
What is the proper way to load a module from a file in to IEX? In the python world, doing something like this pretty standard: from ....
New
shahryarjb
Hello, I get Persian date from my client and convert it to normal calendar like this: def jalali_string_to_miladi_english_number(persi...
New
sorentwo
Hello! tl;dr Announcing Oban, an Ecto based job processing library with a focus on reliability and historical observability. After spen...
977 41022 311
New
srinivasu
How to handle excepions in elixir? Suppose i have A, B, C ,D, E modules. and each module has get() function. A.get() method will call th...
New
aalberti333
As the title describes, I’m trying to run Enum.map() over a list of key/value pairs, where the value is a map. My data looks like this: ...
New
KronicDeth
Elixir plugin for JetBrain’s IntelliJ Platform (including Rubymine) This is a plugin that adds support for Elixir to JetBrains IntelliJ...
289 35421 110
New
chensan
I have a User schema with a :from_id field set to type :string: defmodule TweetBot.Repo.Migrations.CreateUsers do use Ecto.Migration ...
New
qwerescape
Is there a way to get the call stack or stack trace at any point in the code? Not from exceptions, but an expression that returns how the...
New
fayddelight
I tried installing elixir 1.11.2 erlang 23.3.4 via asdf in my zsh shell. Enabled the versions locally and globally. When I list them ...
New
romenigld
I am trying to run a deploy with docker and I successfully runned with this command: docker build -t romenigld/blog-prod . but when I t...
New

We're in Beta

About us Mission Statement