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

Add -Zerror-metrics=PATH to save diagnostic metadata to disk #119355

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

estebank
Copy link
Contributor

Add nightly only flag to store information about encountered errors to disk. The information being tracked is:

  • Error code
  • Path to error being emitted
  • Number of subdiagnostics
  • Number of structured suggestions

@rustbot
Copy link
Collaborator

rustbot commented Dec 27, 2023

r? @compiler-errors

(rustbot has picked a reviewer for you, use r? to override)

@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 Dec 27, 2023
@estebank estebank marked this pull request as ready for review December 27, 2023 18:23
@rust-log-analyzer

This comment has been minimized.

Add nightly only flag to store information about encountered errors
to disk. The information being tracked is:

 - Error code
 - Path to error being emitted
 - Number of subdiagnostics
 - Number of structured suggestions
if let Some(ref mut file) = &mut self.metrics {
let _ = writeln!(
file,
"{:?},{:?},{},{}",
Copy link
Member

Choose a reason for hiding this comment

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

Why are we using this custom format when we already have JSON diagnostic output?

Even if we shouldn't be emitting as much info as JSON-formatted diagnostics, we should perhaps make it easier for arbitrary programs to consume by formatting it like JSON.

let metrics = sopts.unstable_opts.error_metrics.as_ref().and_then(|path| {
let mut path = path.clone();
std::fs::create_dir_all(&path).ok()?;
path.push(format!("error_metrics_{}", std::process::id()));
Copy link
Member

Choose a reason for hiding this comment

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

Why PID? Can we use something more ordered such as YYYY-MM-DD-HH-SS-PID?

@Mark-Simulacrum
Copy link
Member

Does this need to be in rustc? What is the intended consumption workflow (is there intent to stabilize this)? I would expect that ~all of this information is already available to programs running rustc with errors emitted as JSON (e.g., Cargo) and they could handle aggregating and propagating that information.

@bors
Copy link
Contributor

bors commented Jan 5, 2024

☔ The latest upstream changes (presumably #119621) made this pull request unmergeable. Please resolve the merge conflicts.

@compiler-errors
Copy link
Member

@rustbot author

@rustbot rustbot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jan 9, 2024
@Dylan-DPC
Copy link
Member

@estebank any updates on this? thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. 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.

None yet

7 participants