Description
Environment
- Version 0.34.0
Steps to Reproduce
- Create an event-filter that maps WARN logs to Sentry events: https://github.com/firezone/firezone/blob/51d92265f4163967c0045f67495954515da15c62/rust/logging/src/lib.rs#L102-L115
- Attach errors as
&dyn std::error::Error
in a WARN log as advised in the documentation: https://github.com/firezone/firezone/blob/51d92265f4163967c0045f67495954515da15c62/rust/gateway/src/eventloop.rs#L80
Expected Result
To receive a Sentry event that contains the error.
Actual Result
A Sentry event that only contains the log message but not the error:
I've been digging through the source code here and the problem is that when a tracing event gets converted to a Sentry event, all fields apart from what is prefixed with tags.
gets silently dropped:
sentry-rust/sentry-tracing/src/converters.rs
Lines 212 to 230 in a1481d4
This is pretty confusing because the documentation clearly states:
To track error structs, assign a reference to error trait object as field in one of the logging macros. By convention, it is recommended to use the ERROR level and assign it to a field called error, although the integration will also work with all other levels and field names.
What is perhaps missing here is a foot-note that it will work with all levels as long as you configure an event filter that converts the event to a sentry exception! However, instead of fixing the documentation here, I think the proper fix is to actually make this work the way the documentation states and attach the exception to the message, even if the log level is not ERROR.