martosaur

martosaur

Virtually every logging library has a function for manual error reporting:

These functions are often the first to be implemented and date back to the very beginning of the project git history. The intended use case, according to docs I found, is to report handled errors (example 1, example 2)

But every time I see this I’m confused. Why would I want to report an error directly to e.g. Sentry and bypass the logging stack? If I handle an exception and still want to report it, I’m gonna reach for good old Logger.error and let Sentry pick it through the logger handler.

Have you ever seen a legitimate use case for this family of functions? Or perhaps this is the result of some limitation in legacy logging system which made it’s way to all libraries through cross-inspiration?

Showing Posts 1 to 10

dimitarvp

dimitarvp

A database error of the sort “Could not update this record because it now breaks this unique index” is not very useful in isolation. I have used these functions to provide the error’s / exception’s message + extra context i.e. “While trying to connect this paid order to this organization” (bad example, don’t pick on it).

martosaur

martosaur OP

Fair, but that’s also true for Logger.error? You can attach anything to a log message through metadata and it should be correctly picked up by the library handler?

rhcarvalho

rhcarvalho

Many of those APIs were not designed for Elixir, and simply mimic whatever was done in a different ecosystem.

An explicit way to report errors is the “minimal common denominator” for such services.

Then, depending on the ecosystem, functionality gets added on top to leverage the possible ways to do “automatic instrumentation”.

For Elixir, logging is one way. For Python, JS and some other languages there are some global error handlers. For Go things are mostly explicit and manual, etc etc.

cmo

cmo

Sometimes I want to see something in Sentry that isn’t an error. Telemetry could be used for this but it’s very easy to push a message to Sentry.

al2o3cr

al2o3cr

Sometimes the error boundary set up by the tools (for instance: catching exceptions by wrapping controller actions, job perform functions etc) doesn’t meet the code’s needs. It can be useful to capture the failure at the correct boundary and send it to the service before the code takes corrective action (retrying, etc)

One benefit of doing so is that it sends the error through the same tagging / metadata-scrubbing / etc that’s already configured by the library user for “regular” errors, versus bare Logger calls.

LostKobrakai

LostKobrakai

In embedded contexts logging (to disk) and sending data off via the network come with quite different tradeoffs so they‘re not really equal. Yes you could likely still make both work through just the logging interface, but it would be less explicit, more work and harder to understand.

belaustegui

belaustegui

I am the co-maintainer of the ErrorTracker package and can confirm that this is the main reason for manual error tracking.

For example we call an external API service that is sometimes down. The job handles this situation gracefully and provides feedback to the user, so there is no raised error that the library can pick up. When the error happens we report it manually and then continue handling it.

Using Logger is a fine option, but the error tracking packages provide some additional functions such as:

  • Assigning particular errors to users so they can investigate them
  • Attaching comments that provide further clarification
  • Adding additional context (this is also supported by the standard Logger)
  • Marking errors as resolved, or unresolved, etc.
  • Configure notification settings for particular errors
martosaur

martosaur OP

Thanks for the info! I took a deeper look at ErrorTracker source code and it looks like it doesn’t have a logger handler at all? If that’s the case than yeah, it’s totally understandable why manual handling is needed. Logger.error will simply not go through ErrorTracker pipeline.

belaustegui

belaustegui

That’s right!ErrorTracker does not have logger handler at the moment. This is something that we are looking into.

martosaur

martosaur OP

Could you tell me what library you’re using and an example of a tag you have in mind? I’m curious to check if it’s an inherent gap in UX, or perhaps just the way a certain library context is designed.

— 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 94592 917
New
cblavier
Hey there, It’s been more than a year since we started using LiveView as our main UI library and building a whole library of UI componen...
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
heathen
Quite interesting article Google brought me. Didn’t find any mentions about it here. What do you think in general? Would you use togethe...
New
mhanberg
Hi everyone! The first release candidate for the Expert language server project is now available! We’ve published a press release detai...
New
AstonJ
Since we have deprecated our Erlang sections (as we have dedicated Erlang Forums now) let’s add this thread for those who’d like to post ...
New
Null-logic-0
What IDE or editor are you using for Elixir development? Personally, I use Zed, and I really like it, but sometimes I wish there were a ...
New

Other Trending Topics Top

GenericJam
Edit: 2026 May 15 - This post is archived. Mob is alive!! Main docs: mob v0.7.11 — Documentation A bit of explanation for the slightly c...
New
JesseHerrick
Hey, I’m Jesse and I’m the main contributor behind Dexter, a full-featured, lightning-fast Elixir LSP optimized for large codebases. It s...
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
webofbits
With AI doing more of the implementation work, I’ve been wondering how much coding I should deliberately keep doing myself. My main conc...
#ai
New

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews