# Receive errors with Telemetry

**URL:** <https://forum.elixirforum.com/t/receive-errors-with-telemetry/64907>\
**Category:** Questions\
**Tags:** learning-elixir, telemetry\
**Created:** [July 14, 2024, 9:48pm UTC](https://forum.elixirforum.com/t/receive-errors-with-telemetry/64907 "2024-07-14T21:48:07Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![BillBryson](https://forum.elixirforum.com/letter_avatar_proxy/v4/letter/b/43a26b/32.png) [@BillBryson](https://forum.elixirforum.com/u/BillBryson)\
**Post date:** [July 14, 2024, 9:48pm UTC](https://forum.elixirforum.com/t/receive-errors-with-telemetry/64907/1 "2024-07-14T21:48:07Z")

</div>

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:

```elixir
   # 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:

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

```

---

<div class="post-metadata">

**Author:** ![D4no0](https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/d4no0/32/33624_2.png) [@D4no0](https://forum.elixirforum.com/u/D4no0)\
**Post date:** [July 14, 2024, 9:55pm UTC](https://forum.elixirforum.com/t/receive-errors-with-telemetry/64907/2 "2024-07-14T21:55:04Z")

</div>

I think you might be able to do that with a custom logger backend: [Logger — Logger v1.12.3](https://hexdocs.pm/logger/1.12.3/Logger.html#module-elixir-custom-backends)

---

<div class="post-metadata">

**Author:** ![BillBryson](https://forum.elixirforum.com/letter_avatar_proxy/v4/letter/b/43a26b/32.png) [@BillBryson](https://forum.elixirforum.com/u/BillBryson)\
**Post date:** [July 15, 2024, 3:59am UTC](https://forum.elixirforum.com/t/receive-errors-with-telemetry/64907/3 "2024-07-15T03:59:07Z")

</div>

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