Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upNested Spans don't work correctly in JSON logs #704
Comments
|
I think that fixing this should be fairly straightforward. We would want to update this code here: tracing/tracing-subscriber/src/fmt/format/json.rs Lines 86 to 103 in 5a971be and make it behave more like the default formatter, visiting all spans in the trace: tracing/tracing-subscriber/src/fmt/format/mod.rs Lines 664 to 676 in 5a971be I think it would probably make sense to format the spans as a JSON array, in order? We may want to make this configurable. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Bug Report
Version
Platform
Crates
Description
Nesting spans - specifically I'm using
#[instrument]but I assume any method is the same - works great when using the normal text subscriber. But when using the JSON subscriber, only the innermost span details get returned.For example, in the following:
If I call this from a main function as follows:
Then the log outputs are:
Which is exactly as expected. But if I instead use this:
Then the output becomes:
Note that the
spanelement contains "inner" but not "outer".Since JSON logging is especially useful in production environments where you might want to have tooling running off of the structured logs, this is especially frustrating.
Cheers