getsentry / sentry-elixir

The official Elixir SDK for Sentry (sentry.io)
https://sentry.io
MIT License
625 stars 185 forks source link

Logger.warn sent as error with capture_log_messages #428

Closed jhchen closed 4 years ago

jhchen commented 4 years ago

Environment

Description

With capture_log_messages on Logger.warn gets sent to Sentry as an error. Sentry does include the level in the extra metadata so not sure if this behavior is intentional.

CleanShot 2020-09-03 at 12 08 44@2x

It seems the cause is logger_backend.ex:106 sets up the logger_level into the extra metadata and passes through to capture_message, which eventually creates a new Event. Without level set, it will default to error.

Expected Behavior

Sentry would sent the message as a warning

Actual Behavior

Sentry sends as an error

Steps to Reproduce

  1. Turn on capture_log_messages and include at least warnings as minimal level to report
  2. Call Logger.warn("Test")
  3. Observe in sentry.io it gets reported as an error
mitchellhenke commented 4 years ago

Thanks for opening an issue, this makes a lot of sense to do

I've opened #430 to resolve this 🙂

jhchen commented 4 years ago

Thanks for the quick fix @mitchellhenke! Unfortunately there is a bit of a bug with the solution in that :warn is the atom Elixir uses while Sentry only recognizes :warning. I believe this is the only level that has a difference between Elixir and Sentry

mladenml commented 3 years ago

experiencing same behaviour (as jhchen stated) with client version 8.0.2. Screenshot 2020-11-02 at 20 44 35

Is fix for this on roadmap or PRs are welcome?

mitchellhenke commented 3 years ago

Yep, it’s on my list!

aus70 commented 1 year ago

I'm seeing again the same issue: when I send a Logger.warn or Logger.warning, the level is error, the logger_level is warn. Regression? Am I missing anything?