martosaur
What is the use case for manual error reporting in logging libraries?
Virtually every logging library has a function for manual error reporting:
Sentry.capture_exception/2Appsignal.set_error/3ErrorTracker.report/3DiscoLog.error/4Tower.report/4
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?
Most Liked
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.
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).
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.
Popular in Discussions
Other popular topics
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
- #channels
- #elixirconf
- #exunit
- #discussion
- #code-sync
- #javascript
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixir-ls
- #phoenix_html
- #iex
- #blog-post
- #graphql
- #genstage
- #ai
- #websockets
- #supervisor
- #advent-of-code
- #elixirconf-us
- #distillery
- #processes
- #forms
- #api
- #metaprogramming
- #security
- #performance








