tracing
tracing copied to clipboard
Consider enabling `tracing_subscriber::fmt::format::FmtSpan::CLOSE` by default?
At the moment, if one uses only spans and no events, the logs will be empty by default, which is a bit confusing. Printing something for spans would be helpful. Printing something on close would allow to print the timing info, and that's might be pretty valuable default.
I'm open to this, although I was initially pretty leery about printing anything related to span events by default since I feel like it has the potential to get a bit noisy.
There's been some conversation in the past about whether changing the default behavior should be considered a breaking change --- the code will still build, but it might suddenly start doing something you don't want. So, depending on what people think, this might need to wait for v0.3.
It would be nice to get more feedback from other users on whether or not changing the default behavior is a good idea.
I wouldn't like that to be the default, it would add a lot of extra printouts and I personally do use the default for my default logging. Adding it to the subscriber builder and showing it among the code examples in the documentation seems like an approach that should keep most people happy.
I wouldn't like that to be the default, it would add a lot of extra printouts and I personally do use the default for my default logging. Adding it to the subscriber builder and showing it among the code examples in the documentation seems like an approach that should keep most people happy.
+1 to this point. I'm not sure that printing information on close is the correct behavior for tracing_subscriber::fmt
by default, but I think adding documentation in a prominent location showing how this can be enabled would get us pretty far.
To clarify why default would be useful for me: I don't use events at all, I use exclusively spans (as they give you anything events do, plus a timing information). So for me, the fmt subscriber produces empty output by default.
To clarify why default would be useful for me: I don't use events at all, I use exclusively spans (as they give you anything events do, plus a timing information). So for me, the fmt subscriber produces empty output by default.
Ah, I see. Some context: tracing_subscriber::fmt
is heavily optimized around "span-enriched logs", not "lots of span data". To avoid having people make their own layers/subscriber, we added an option to emit this information.
I'm thinking that it might make sense to create a dedicated subscriber for the "lots of span data" use-case and keep the existing fmt::Subscriber
as-is. By reusing the formatting infrastructure in tracing_subscriber
, it might not be too much work. What do you think, @matklad?
I agree with having a default that print something, it was really confusing to not see anything when I try to use the crates, I was setting the log level to trace and still not see anything, and as the doc is not very easy at the moment to read, it takes me time and thinking to understand what was wrong.
Personally, I think .with_span_events(FmtSpan::NEW | FmtSpan::CLOSE)
should be the default.
Ah, I see. Some context: tracing_subscriber::fmt is heavily optimized around "span-enriched logs", not "lots of span data".
I don't get it.
Just wanted to chime in here to say that I was pretty confused why my additions of #[tracing::instrument]
weren't showing anything when tracing::info!
was. Not sure what the right answer is here for a default, but something to consider might be printing a message the first time that a span is seen if this hasn't been configured and it's in debug mode? That wouldn't spam any logs, but would point people in the right direction to figure out how to get this information if they need it.