BillBryson

BillBryson

Receive errors with Telemetry

Hello, I am trying to learn more about Telemetry events in Elixir and to do that I am building an Elixir “error monitoring” package.

I currently am able to receive some Phoenix errors with the following telemetry event handler:

   # application.ex
   :telemetry.attach("phoenix-stop-handler", [:phoenix, :endpoint, :stop], &Foobar.TelemetryHandler.handle_event/4, nil)
   
   # Foobar.TelemetryHandler
   def handle_event([:phoenix, :endpoint, :stop], measurements, metadata, _config) do
     case metadata[:reason] do
       {:error, reason} ->
         Foobar.capture_error(reason, metadata)
       _ ->
         :ok
     end
   end

However, I’m wondering if it’s possible to easily tie into all Elixir application errors? I envision something like this, but not sure if this is possible:

   def handle_event([:any, :application, :error], measurements, metadata, _config) do
     case metadata[:reason] do
       {:error, reason} ->
         Foobar.capture_error(reason, metadata)
       _ ->
         :ok
     end
   end

First Post!

D4no0

D4no0

I think you might be able to do that with a custom logger backend: Logger — Logger v1.12.3

Last Post!

BillBryson

BillBryson

I hadn’t considered this and will look into it. Thank you.

Where Next?

Popular in Questions Top

rms.mrcs
Hi, I need to transform a list of numbers into a map where the keys are the indexes and the values are the original values of the list. ...
New
New
hariharasudhan94
lets say i have a sample like a = 20; b = 10; if (a > b) do {:ok, "a"} end if (a < b) do {:ok, b} end if (a == b) do {:ok, "equa...
New
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
PeterCarter
There are pre-rolled solutions for other frameworks that do work. However, Phoenix does not seem to have these. Have people had good expe...
New
fireproofsocks
Forgive me if this is obvious, but how does one delete a database record WITHOUT selecting it first? Ecto.Repo — Ecto v3.14.0 has exampl...
New
siddhant3030
Hi, I have to write a raw query for one of my project. But till now I have used ecto queries and don’t have much experience writing raw ...
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
dokuzbir
I want to highlight html closing tags when i click a html tag. That works in .html files but doesnt work for html.eex templates. How can...
New
gausby
I asked this very same question on twitter and got some interesting feedback, but I thought it would be a good question to ask here as we...
1207 40082 209
New
albydarned
Hello all! I am typing this post from my new MacBook Pro with the M1 chip. I’m loving it so far, and will probably use it as my daily dr...
New
TunkShif
This post is an instruction guide to help you setup your Neovim for Elixir development from scratch. It includes general information on h...
274 42576 114
New
AstonJ
Posting this to see if we can make things easier for people to get into Neovim. If you use Neovim and have a favourite distro please let ...
New

We're in Beta

About us Mission Statement