Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

subscriber: record error source with Json format #2784

Open
BugenZhao opened this issue Nov 2, 2023 · 2 comments
Open

subscriber: record error source with Json format #2784

BugenZhao opened this issue Nov 2, 2023 · 2 comments

Comments

@BugenZhao
Copy link

Feature Request

Crates

tracing-subscriber

Motivation

There's no strong convention for how an Error should display itself. However, an increasing number of crates no longer include the error source in their Display implementation any more (aws-sdk for example: awslabs/aws-sdk-rust#657). So it becomes the callers' or the loggers' responsibility to visit the source chain and get them formatted.

We already done this in the DefaultVisitor and PrettyVisitor for the fmt layer. And I'm wondering whether we should also handle the sources in JsonVisitor as well.

Proposal

Override Visit::record_error in JsonVisitor, add additional field named <field>.sources with type string[] for error sources (if exist).

Alternatives

@SuperFluffy
Copy link

I was also caught by this recently changing from the tracing subscriber pretty-printer to json-formatter.

I am investigating alternatives to fmt::Subscriber, but it would be nice if it picked up the error sources as well.

@evbo
Copy link

evbo commented Apr 26, 2024

can anyone share how you currently use tracing::error! in an AWS lambda in order for it to log error messages correctly?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants