You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This means that any implementation of format_event loses the original error when returning. This makes it more difficult for the user to be able to figure out why something went wrong. One concrete example is the JSON formatter. If there is an error during serialization, tracing-subscriber is able to let the user know there was an error (once #2102 is merged) but not why.
Proposal
Update the format_event function's return type to allow arbitrary errors. This way, we can retain the original error when something goes wrong and the caller of the function can take the error and do something with it.
Along with this, we should update the JSON formatter to pass the error back up:
Instead of propagating the error back up, have each format_event implementation print out the errors to stderr on their own
Downside: User-provided FormatEvent impls may forget to include this
Downside: Don't have access to the same Writer as the Writer that is used for the traces themselves (unless we add that as a parameter in format_event, which is a breaking change too)
Considerations
This is a breaking change. It would only be able to be included in tracing-subscriber 0.4 or later.
The text was updated successfully, but these errors were encountered:
Hi, I would be interested in picking this up and was hoping you could clarify what sort of new error type are we looking at? The usual Box<dyn Error + Sync + Send>? If yes, do you think we should use the standard Result type or expose a public type alias like pub type FmtError = std::result::Result<(), Box<dyn Error>>;.
Feature Request
Crates
tracing-subscriber
Motivation
Currently, the
FormatEvent
trait'sformat_event
function has a return type offmt::Result
:tracing/tracing-subscriber/src/fmt/format/mod.rs
Lines 201 to 206 in 45c0a10
fmt::Result
is defined asThis means that any implementation of
format_event
loses the original error when returning. This makes it more difficult for the user to be able to figure out why something went wrong. One concrete example is the JSON formatter. If there is an error during serialization, tracing-subscriber is able to let the user know there was an error (once #2102 is merged) but not why.Proposal
Update the
format_event
function's return type to allow arbitrary errors. This way, we can retain the original error when something goes wrong and the caller of the function can take the error and do something with it.Along with this, we should update the JSON formatter to pass the error back up:
tracing/tracing-subscriber/src/fmt/format/json.rs
Line 327 in 45c0a10
Alternatives
format_event
implementation print out the errors to stderr on their ownFormatEvent
impls may forget to include thisformat_event
, which is a breaking change too)Considerations
This is a breaking change. It would only be able to be included in tracing-subscriber 0.4 or later.
The text was updated successfully, but these errors were encountered: