halostatue

halostatue

Cost of stack traces for logging?

We were having a discussion at work about logging:

I was thinking about the pros and cons of adding stack traces to log metadata last week, and the difference between the messages we log for helping operate the system and the messages which get presented to the real end user (see kevlinhenney on twitter for endless examples of diagnostics ending up in user interfaces).I was wondering about having a function to automatically bundle stacktrace information into a log message so we could do something like:

# stripped down code to handle a failure # e.g. {:error, posix} = File.open(filename)
message = "Failed to open #{filename}" #{:file.format_error(posix)}
OurLogger.error(message)
{:error, message}

And OurLogger could massage and add stacktrace: Process.info(self(), :current_stacktrace) to the metadata. The log formatter could then display stack traces for error and higher?Then the application sending a result to the eventual human would have to make sure it presented an appropriate message for the user.

This sounds…possible, but it feels like it would be very expensive to achieve. Obviously, we’d never implement this without benchmarking getting a stacktrace, but what I wonder is whether cost is that high?

If it’s low, would there be a reason to add this to Elixir’s logger by default?

Most Liked

hauleth

hauleth

If you log anything above error and you do not crash at least process, then I think that you use logging system incorrectly.

To extend a little on levels error and above:

halostatue

halostatue

@NobbZ The example given was illustrative only. There are plenty of cases where something is an error, but potentially recoverable—especially when dealing with external systems (this is mostly what our services do).

In general, I agree with @hauleth’s levels, although to me alert is more right here, right now.

Thanks for the thoughts on this; it confirms the feeling that I had on the cost of stacktrace acquisition.

Where Next?

Popular in Discussions Top

pillaiindu
In django there is a cache framework backed by memcached. Rails also puts a lot of emphasis on caching, and even the idea of russian-doll...
New
arcanemachine
https://nitter.net/josevalim/status/1744395345872683471 https://twitter.com/josevalim/status/1744395345872683471
New
lucaong
Hello Elixir and Nerves community, I have been working for a while on an open-source embedded key-value database for Elixir, that I call...
230 13924 124
New
nburkley
AWS re:Invent is on at the moment with some interesting announcements. One new feature in particular is the Lambda Runtime API for AWS La...
New
AstonJ
If a newbie asked you about Phoenix Contexts, how would you explain the basics to them? Feel free to be as concise or in-depth as you li...
New
mbenatti
Following https://github.com/tbrand/which_is_the_fastest |> https://raw.githubusercontent.com/tbrand/which_is_the_fastest/master/imgs...
New
Ankhers
Just a little information upfront. Generally speaking, if I feel like I need to either break a pipe chain or use an anonymous function in...
New
New
PragTob
Hey everyone, this has been on my mind for some time and I’d love your input on it! TLDR: I feel like maps are superioer for storing and...
New
klo
Got a question about when to concat vs. prepending items to list then reversing to achieve appending. So i know lists boil down to [1 | ...
New

Other popular topics Top

danschultzer
None of the current solutions worked well for me, so I went ahead and built a user management system from scratch. This project took far...
548 29377 241
New
Darmani72
If I have a post route which an argument: post /my_post_route/:my_param1, MyController.my_post_handler How would get the post params ...
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 41539 114
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
electic
Hi, I am new to Elixir. I am trying to use the DateTime component to insert a date into MySQL however the there seems to be no way to fo...
New
aesmail
Hello guys, I have finally made it. I created an admin interface for a framework. It’s been on my todo list for years and with the curre...
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 39297 209
New
Qqwy
Original source of discussion: This topic on the Pragmatic Programmers’ Functional Web Development with Elixir, OTP, and Phoenix forum. ...
New
shijith.k
I am trying to start a new phoenix project with elixir 1.9, but mix phx.new does not work. It says that ** (Mix) The task "phx.new" could...
New
dogweather
I wrote this comment on r/haskell, and it’s not popular there. :wink: But I think I’m on to something… Haskell reminds me of Java, and e...
New

We're in Beta

About us Mission Statement