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

rustc_resolve: use structured fields in traces #135676

Merged
merged 1 commit into from
Jan 20, 2025

Conversation

yotamofek
Copy link
Contributor

I think this crate was written before tracing was adopted, and was manually writing fields into trace logs instead of using structured fields.

I kept function names in the trace messages even though I added #[instrument] invocations so that the events will be in named spans, wasn't sure if spans are always printed.

@rustbot
Copy link
Collaborator

rustbot commented Jan 18, 2025

r? @BoxyUwU

rustbot has assigned @BoxyUwU.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Jan 18, 2025
Copy link
Member

@compiler-errors compiler-errors left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(don't make another commit, just amend the existing one).

"find_span_immediately_after_crate_name: module_name={:?} use_span={:?}",
module_name, use_span
);
debug!("find_span_immediately_after_crate_name",);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there's no need to repeat the name of the function here and elsewhere; please remove.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you think should be the message instead? Something like debug!("entered")?
(in the places where fields are added I can just remove the message)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not totally certain that they're even adding much value to keep around at all.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed those, then. (and the instrumentation for the containing fns)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why remove the instrument annotation. #[instrument(level = "debug", skip(...))] should "just work" without any dummy debug! statement in the body shouldn't it?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, you're absolutely right. I thought it only created spans but no "enter" event. I was also creating info-level spans by accident. Fixed.

@yotamofek yotamofek force-pushed the resolve-cleanups branch 3 times, most recently from a70ca63 to 5f1bf88 Compare January 19, 2025 07:14
Copy link
Member

@BoxyUwU BoxyUwU left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

path has since been mutated so its not redundant with the #[instrument debug on the function

compiler/rustc_resolve/src/diagnostics.rs Outdated Show resolved Hide resolved
compiler/rustc_resolve/src/diagnostics.rs Outdated Show resolved Hide resolved
@yotamofek
Copy link
Contributor Author

path has since been mutated so its not redundant with the #[instrument debug on the function

Oh, right, thanks! Fixed. (in two other places too)

@BoxyUwU
Copy link
Member

BoxyUwU commented Jan 20, 2025

@bors r+ rollup

@bors
Copy link
Contributor

bors commented Jan 20, 2025

📌 Commit 539b4d8 has been approved by BoxyUwU

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jan 20, 2025
bors added a commit to rust-lang-ci/rust that referenced this pull request Jan 20, 2025
Rollup of 5 pull requests

Successful merges:

 - rust-lang#135433 (Add Profile Override for Non-Git Sources)
 - rust-lang#135626 (doc: Point to methods on `Command` as alternatives to `set/remove_var`)
 - rust-lang#135658 (Do not include GCC source code in source tarballs)
 - rust-lang#135676 (rustc_resolve: use structured fields in traces)
 - rust-lang#135762 (Correct counting to four in cell module docs)

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit 3e26673 into rust-lang:master Jan 20, 2025
6 checks passed
@rustbot rustbot added this to the 1.86.0 milestone Jan 20, 2025
rust-timer added a commit to rust-lang-ci/rust that referenced this pull request Jan 20, 2025
Rollup merge of rust-lang#135676 - yotamofek:resolve-cleanups, r=BoxyUwU

rustc_resolve: use structured fields in traces

I think this crate was written before `tracing` was adopted, and was manually writing fields into trace logs instead of using structured fields.

I kept function names in the trace messages even though I added `#[instrument]` invocations so that the events will be in named spans, wasn't sure if spans are always printed.
@yotamofek yotamofek deleted the resolve-cleanups branch January 20, 2025 20:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants