halostatue

halostatue

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?

Showing Posts 1 to 3

NobbZ

NobbZ

As implicit stack traces have been removed in favor of explicit stacktraces due to their cost, it is safe to assume that it will be far to expensive to always log them.

For errors and above though, I think it totally depends on the error. Are you really able to learn anything new from an attached stacktrace, or is File/Function metadata already enough, as there are basically only 2 or less pathes that this function will ever be called?

When you log an error or above, why do you prefer to log the error, rather than crash? Error for me means “this is a condition the process can not recover from, it will not proceed”, while “above error” for me even means “this application is unable to recover from the condition, it will shut down”.

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 OP

@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.

— All posts loaded —

Where Next? Top

Trending in Discussions Top

AstonJ
As the title says, please share what you’ve been up to with Elixir. Whether that’s been learning it, looking into it, making stuff with i...
2977 92995 915
New
caslu
I want to open this thread for you all to discuss and help those who really like Ash but are still hesitant to use it in a real project. ...
New
mudasobwa
I am happy to introduce the very α version of the new programming language compiled to BEAM. Welcome Cure. It has literally three kille...
New
GES233
I’m posting this in response to Jose’s recent tweet (Cr. link) : People are sleeping on Elixir for a coding harness: Hot-code swappi...
New
_mfierro
Hello, I wrote Stop My Hand, a Scattergories-like web application using Phoenix/LiveView as my learning project for Elixir (after readin...
New
marciol
It would be helpful to have a list of companies worldwide that hire engineers without prior experience in Elixir. Often, it can be quite ...
New
durvia
Anyone running long-lived stateful processes on BEAM? We’re building an AI agent runtime and would love to compare notes. We’re a small ...
New

Other Trending Topics Top

garrison
Hobbes is a low-level distributed database for the Elixir programming language. Hobbes provides a simple, safe, and scalable storage lay...
New
marciok
Hi there! We created Gust: A task orchestrator inspired by Airflow. For those who have never heard about Aiflow, it’s a Python-based wor...
New
jimsynz
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
Dmk
Xamal is a deployment tool for Elixir apps that deploys native releases to bare metal servers over SSH. It’s a port of GitHub - basecamp/...
New
Damirados
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
wintermeyer
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

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews