axelson
Scenic Core Team
Is there a way to get Telemetry to output the full exception when a handler crashes?
It’s a little difficult to debug when you only get a message like this:
[error] Handler "my-app-handler-id" has failed and has been detached. Class=:error
Reason=:undef
Stacktrace=[
{Logger, :info, ["GET /posts served in 2ms"], []},
{:telemetry, :"-execute/3-fun-0-", 4,
[
...
In particular the Reason=:undef feels cryptic compared to a normally formatted exception, but also it would be easier to read the stacktrace if it was formatted as if from Exception.format_stacktrace/1.
Also is there an easy way to re-attach the handler so I can test the updated code without restarting the server?
Trending in Questions
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
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
I have what I’ve heard referred to as a “lookup table” in my database. This is a way of assigning codes to common values. One common lo...
New
What approach to take when sending live updates to “random” users Hi! I have a question, I have a little chat app, and when I create a DM...
New
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
Anyone here using Honeybadger?
My Honeybadger account is being overwhelmed with noise from some bots. Seeing a lot of
Bandit.HTTPError...
New
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
Other Trending Topics
I am happy to introduce the very α version of the new programming language compiled to BEAM.
Welcome Cure.
It has literally three kille...
New
Hobbes is a low-level distributed database for the Elixir programming language.
Hobbes provides a simple, safe, and scalable storage lay...
New
ExRatatui lets you cook up rich terminal UIs in Elixir, powered by Rust’s ratatui via Rustler NIFs. Build interactive terminal applicatio...
New
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
Corex is an accessible, unstyled UI component library for Phoenix that integrates Zag.js state machines using Vanilla JavaScript and Live...
New
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
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #elixirconf
- #channels
- #exunit
- #discussion
- #code-sync
- #javascript
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #blog-post
- #elixir-ls
- #ai
- #elixirconf-us
- #phoenix_html
- #iex
- #graphql
- #genstage
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #hex
- #security
- #metaprogramming










Showing Posts 1 to 10- Show Best Posts
- Show All (oldest first)
- Show All (newest first)
LostKobrakai
That’s erlang errors in a nutshell – it’s the error for module or function undefined. We usually don’t see them because of the elixir logger translator if this bubbles up, but telemetry doesn’t let this bubble to not break the place the handler was called in. And with it being an erlang library it also cannot use any of the elixir level translation after having cought the error.
What might be possible is having an
telemetry_translatorelixir library, which can translate the telemetry logs specifically by extracting the relevant data.dimitarvp
How would that look? What are the example inputs it has to handle? E.g. just the
:undefatom?axelson
Hmm, then maybe what I’m asking/looking for is for
:telemetryto support a configuration (intended for development) that does let the error bubble so that we can get a full error message.D4no0
I don’t know if that is idiomatic, however the way I used to debug this back in the day was to wrap the handler code in a
try/catchblock and just print the error in the console.LostKobrakai
The elixir translator is implemented as a logger filter, which transforms the log messages it receives. You can find information around how those filters work over in the otp docs for logger.
axelson
Ah, that’s a great tip! I forget how I introduced the original error in the OP but by adding this to the end my telemetry handler:
I can turn this error:
Into this much easier to read error:
And I think with the original
Reason=:undeferror the difference would be even more drastic!I’ve marked your post as the solution since it’s a very practical way to approach this, but I’d still love an easier way to debug this without having to modify the handler itself.
Now I just need to remember to not accidentally commit that change
LostKobrakai
What is a “full error message” though. What you’re seeing is afaik all you get for erlang errors. It’s also all the elixir logger translator would see and turn into a more friendly sounding exception, but still without more details.
Elixir however also has the
Exception.blamecallback, which for exceptions can be used to include more context, which might be too expensive to produce in production environments. That’s again a pure elixir concept though.That’s a great tip, especially given I doubt telemetry would add an option for customizing this.
With reraise you even get the same behaviour against telemetry instead of hiding the failure.
axelson
By “full error message” I mean:
instead of:
The second isn’t really even an error message (in my view) I’d consider it just an “error” since there’s no “message” describing the error.
A better name would probably be an “elixir-formatted” error message.
Yeah adding
reraisedefinitely makes sense if you’re adding this to production. But for me in development I’d skip thereraisesince otherwise if there’s many requests happening then I might miss the initial disconnection error due to all the other log output. Of course the downside is that the telemetry handler may be printing lots of errors, but generally I want errors to be quite noisy in dev so that I can find and fix them.D4no0
You can make it as fancy as you want it to be, for example you could set a config value to enable/disable this. Then all you have to do is have a wrapper function over all your handlers.
axelson
If that’s true then maybe the best approach would be a dev-only Telemetry library that is drop-in compatible with
:telemetry.