-
Notifications
You must be signed in to change notification settings - Fork 13.2k
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -41,6 +41,7 @@ use std::any::Any; | |
use std::cell::{self, RefCell}; | ||
use std::env; | ||
use std::fmt; | ||
use std::fs::File; | ||
use std::ops::{Div, Mul}; | ||
use std::path::{Path, PathBuf}; | ||
use std::str::FromStr; | ||
|
@@ -1009,6 +1010,12 @@ fn default_emitter( | |
); | ||
Box::new(emitter.ui_testing(sopts.unstable_opts.ui_testing)) | ||
} else { | ||
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())); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why PID? Can we use something more ordered such as There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I am not sure of the precise reasoning behind using PID, but I have no objections to switching to datetime-pid. We can definitely use that instead. |
||
File::options().create(true).append(true).open(&path).ok() | ||
}); | ||
let emitter = EmitterWriter::stderr(color_config, fallback_bundle) | ||
.fluent_bundle(bundle) | ||
.sm(Some(source_map)) | ||
|
@@ -1018,6 +1025,7 @@ fn default_emitter( | |
.macro_backtrace(macro_backtrace) | ||
.track_diagnostics(track_diagnostics) | ||
.terminal_url(terminal_url) | ||
.metrics(metrics) | ||
.ignored_directories_in_source_blocks( | ||
sopts.unstable_opts.ignore_directory_in_diagnostics_source_blocks.clone(), | ||
); | ||
|
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's no particular reason; I think the goal here was just to get something in initially so that the flag wasn't just sitting around as dead code. After some discussion, we've decided to go more in the direction that Mark suggested and lean on downstream consumers of the JSON (specifically cargo) for the specific metrics included in this PR. For now, we're going to focus on the ICE reporting mechanism as the initial metric to coexist with the flag since that's actually the one we care about the most.