Repository navigation
Setup tracing-tree for hierarchical debug traces - #7188
Merged
Merged
Conversation
Member
Author
Member
Author
|
r? @ytmimi |
1 of 4 tasks
jieyouxu
commented
Oct 16, 2026
jieyouxu
commented
Oct 16, 2026
Comment on lines
+59
to
+63
| let layer = HierarchicalLayer::default() | ||
| .with_writer(std::io::stderr) | ||
| .with_targets(true) | ||
| .with_bracketed_fields(true) | ||
| .with_indent_amount(2); |
Member
Author
There was a problem hiding this comment.
(These are stylistic options that can be tuned.)
ytmimi
approved these changes
Oct 16, 2026
Contributor
There was a problem hiding this comment.
Definitely in favor of making this change. I've often struggled to keep track of things in the logs, so having a nested structure would help out a lot!
@jieyouxu I'll let you add this to the merge queue when you think it's ready since I see the DO NOT MERGE comment.
jieyouxu
force-pushed
the
jieyouxu/tracing-tree
branch
from
October 16, 2026 14:02
23b5b28 to
a1b3036
Compare
Member
Author
|
Dropped the DO NOT MERGE commit, no other changes. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.


Motivation
We already use
tracingin rustfmt for various debug tracing. Right now, the traces are flat, and sometimes I find it hard to follow where debug traces are emitted, and what the call stack/tree is.Tracking issue: #7189
Implementation
Inspired by rustc's hierarchical traces, this PR introduces
tracing-tree(which is used by rustc) so we can introduce more structured debug tracing.Note that the hierarchy is only well-established by systematically introducing
#[instrument](or equivalent) to key functions so that we can emit tracing spans, and establish relationships between such tracing spans. Without systematic#[instrument]tracing spans, this PR is essentially a no-op.I will provide some example outputs as comments.
Follow-up work
This PR only sets up the initial infra. In follow-up PRs, I intend to:
#[instrument]to key functionsNotes for the reviewer
I intentionally included a DO NOT MERGE commit demonstrating theEDIT: now dropped.#[instrument]usages.Discussed previously in #t-rustfmt > tracing-tree?.