Add export of bootstrap tracing to Chrome events
This commit is contained in:
parent
d7eca8ac15
commit
447a6a0322
8 changed files with 35 additions and 11 deletions
|
@ -59,6 +59,7 @@ dependencies = [
|
||||||
"termcolor",
|
"termcolor",
|
||||||
"toml",
|
"toml",
|
||||||
"tracing",
|
"tracing",
|
||||||
|
"tracing-chrome",
|
||||||
"tracing-subscriber",
|
"tracing-subscriber",
|
||||||
"tracing-tree",
|
"tracing-tree",
|
||||||
"walkdir",
|
"walkdir",
|
||||||
|
@ -727,6 +728,17 @@ dependencies = [
|
||||||
"syn",
|
"syn",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "tracing-chrome"
|
||||||
|
version = "0.7.2"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "bf0a738ed5d6450a9fb96e86a23ad808de2b727fd1394585da5cdd6788ffe724"
|
||||||
|
dependencies = [
|
||||||
|
"serde_json",
|
||||||
|
"tracing-core",
|
||||||
|
"tracing-subscriber",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "tracing-core"
|
name = "tracing-core"
|
||||||
version = "0.1.33"
|
version = "0.1.33"
|
||||||
|
|
|
@ -7,7 +7,7 @@ default-run = "bootstrap"
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
build-metrics = ["sysinfo"]
|
build-metrics = ["sysinfo"]
|
||||||
tracing = ["dep:tracing", "dep:tracing-subscriber", "dep:tracing-tree"]
|
tracing = ["dep:tracing", "dep:tracing-chrome", "dep:tracing-subscriber", "dep:tracing-tree"]
|
||||||
|
|
||||||
[lib]
|
[lib]
|
||||||
path = "src/lib.rs"
|
path = "src/lib.rs"
|
||||||
|
@ -67,6 +67,7 @@ sysinfo = { version = "0.33.0", default-features = false, optional = true, featu
|
||||||
|
|
||||||
# Dependencies needed by the `tracing` feature
|
# Dependencies needed by the `tracing` feature
|
||||||
tracing = { version = "0.1", optional = true, features = ["attributes"] }
|
tracing = { version = "0.1", optional = true, features = ["attributes"] }
|
||||||
|
tracing-chrome = { version = "0.7", optional = true }
|
||||||
tracing-subscriber = { version = "0.3", optional = true, features = ["env-filter", "fmt", "registry", "std"] }
|
tracing-subscriber = { version = "0.3", optional = true, features = ["env-filter", "fmt", "registry", "std"] }
|
||||||
tracing-tree = { version = "0.4.0", optional = true }
|
tracing-tree = { version = "0.4.0", optional = true }
|
||||||
|
|
||||||
|
|
|
@ -21,7 +21,7 @@ use tracing::instrument;
|
||||||
#[cfg_attr(feature = "tracing", instrument(level = "trace", name = "main"))]
|
#[cfg_attr(feature = "tracing", instrument(level = "trace", name = "main"))]
|
||||||
fn main() {
|
fn main() {
|
||||||
#[cfg(feature = "tracing")]
|
#[cfg(feature = "tracing")]
|
||||||
setup_tracing();
|
let _guard = setup_tracing();
|
||||||
|
|
||||||
let args = env::args().skip(1).collect::<Vec<_>>();
|
let args = env::args().skip(1).collect::<Vec<_>>();
|
||||||
|
|
||||||
|
@ -210,7 +210,7 @@ fn check_version(config: &Config) -> Option<String> {
|
||||||
// - `tracing`'s `#[instrument(..)]` macro will need to be gated like `#![cfg_attr(feature =
|
// - `tracing`'s `#[instrument(..)]` macro will need to be gated like `#![cfg_attr(feature =
|
||||||
// "tracing", instrument(..))]`.
|
// "tracing", instrument(..))]`.
|
||||||
#[cfg(feature = "tracing")]
|
#[cfg(feature = "tracing")]
|
||||||
fn setup_tracing() {
|
fn setup_tracing() -> impl Drop {
|
||||||
use tracing_subscriber::EnvFilter;
|
use tracing_subscriber::EnvFilter;
|
||||||
use tracing_subscriber::layer::SubscriberExt;
|
use tracing_subscriber::layer::SubscriberExt;
|
||||||
|
|
||||||
|
@ -218,7 +218,17 @@ fn setup_tracing() {
|
||||||
// cf. <https://docs.rs/tracing-tree/latest/tracing_tree/struct.HierarchicalLayer.html>.
|
// cf. <https://docs.rs/tracing-tree/latest/tracing_tree/struct.HierarchicalLayer.html>.
|
||||||
let layer = tracing_tree::HierarchicalLayer::default().with_targets(true).with_indent_amount(2);
|
let layer = tracing_tree::HierarchicalLayer::default().with_targets(true).with_indent_amount(2);
|
||||||
|
|
||||||
let registry = tracing_subscriber::registry().with(filter).with(layer);
|
let mut chrome_layer = tracing_chrome::ChromeLayerBuilder::new().include_args(true);
|
||||||
|
|
||||||
|
// Writes the Chrome profile to trace-<unix-timestamp>.json if enabled
|
||||||
|
if !env::var("BOOTSTRAP_PROFILE").is_ok_and(|v| v == "1") {
|
||||||
|
chrome_layer = chrome_layer.writer(io::sink());
|
||||||
|
}
|
||||||
|
|
||||||
|
let (chrome_layer, _guard) = chrome_layer.build();
|
||||||
|
|
||||||
|
let registry = tracing_subscriber::registry().with(filter).with(layer).with(chrome_layer);
|
||||||
|
|
||||||
tracing::subscriber::set_global_default(registry).unwrap();
|
tracing::subscriber::set_global_default(registry).unwrap();
|
||||||
|
_guard
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,7 +30,7 @@ use crate::utils::exec::command;
|
||||||
use crate::utils::helpers::{
|
use crate::utils::helpers::{
|
||||||
exe, get_clang_cl_resource_dir, is_debug_info, is_dylib, symlink_dir, t, up_to_date,
|
exe, get_clang_cl_resource_dir, is_debug_info, is_dylib, symlink_dir, t, up_to_date,
|
||||||
};
|
};
|
||||||
use crate::{CLang, Compiler, DependencyType, GitRepo, LLVM_TOOLS, Mode, trace_cmd};
|
use crate::{CLang, Compiler, DependencyType, GitRepo, LLVM_TOOLS, Mode};
|
||||||
|
|
||||||
#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
||||||
pub struct Std {
|
pub struct Std {
|
||||||
|
@ -2235,7 +2235,8 @@ pub fn stream_cargo(
|
||||||
) -> bool {
|
) -> bool {
|
||||||
let mut cmd = cargo.into_cmd();
|
let mut cmd = cargo.into_cmd();
|
||||||
|
|
||||||
let _run_span = trace_cmd!(cmd);
|
#[cfg(feature = "tracing")]
|
||||||
|
let _run_span = crate::trace_cmd!(cmd);
|
||||||
|
|
||||||
let cargo = cmd.as_command_mut();
|
let cargo = cmd.as_command_mut();
|
||||||
// Instruct Cargo to give us json messages on stdout, critically leaving
|
// Instruct Cargo to give us json messages on stdout, critically leaving
|
||||||
|
|
|
@ -905,6 +905,7 @@ impl Build {
|
||||||
return CommandOutput::default();
|
return CommandOutput::default();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(feature = "tracing")]
|
||||||
let _run_span = trace_cmd!(command);
|
let _run_span = trace_cmd!(command);
|
||||||
|
|
||||||
let created_at = command.get_created_location();
|
let created_at = command.get_created_location();
|
||||||
|
|
|
@ -347,7 +347,7 @@ impl FormatShortCmd for Command {
|
||||||
fn format_short_cmd(&self) -> String {
|
fn format_short_cmd(&self) -> String {
|
||||||
let program = Path::new(self.get_program());
|
let program = Path::new(self.get_program());
|
||||||
let mut line = vec![program.file_name().unwrap().to_str().unwrap()];
|
let mut line = vec![program.file_name().unwrap().to_str().unwrap()];
|
||||||
line.extend(self.get_args().into_iter().map(|arg| arg.to_str().unwrap()));
|
line.extend(self.get_args().map(|arg| arg.to_str().unwrap()));
|
||||||
line.join(" ")
|
line.join(" ")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,11 +13,11 @@ use std::{env, fs, io, str};
|
||||||
use build_helper::util::fail;
|
use build_helper::util::fail;
|
||||||
use object::read::archive::ArchiveFile;
|
use object::read::archive::ArchiveFile;
|
||||||
|
|
||||||
|
use crate::LldMode;
|
||||||
use crate::core::builder::Builder;
|
use crate::core::builder::Builder;
|
||||||
use crate::core::config::{Config, TargetSelection};
|
use crate::core::config::{Config, TargetSelection};
|
||||||
use crate::utils::exec::{BootstrapCommand, command};
|
use crate::utils::exec::{BootstrapCommand, command};
|
||||||
pub use crate::utils::shared_helpers::{dylib_path, dylib_path_var};
|
pub use crate::utils::shared_helpers::{dylib_path, dylib_path_var};
|
||||||
use crate::{LldMode, trace_cmd};
|
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests;
|
mod tests;
|
||||||
|
@ -265,7 +265,8 @@ pub fn make(host: &str) -> PathBuf {
|
||||||
|
|
||||||
#[track_caller]
|
#[track_caller]
|
||||||
pub fn output(cmd: &mut Command) -> String {
|
pub fn output(cmd: &mut Command) -> String {
|
||||||
let _run_span = trace_cmd!(cmd);
|
#[cfg(feature = "tracing")]
|
||||||
|
let _run_span = crate::trace_cmd!(cmd);
|
||||||
|
|
||||||
let output = match cmd.stderr(Stdio::inherit()).output() {
|
let output = match cmd.stderr(Stdio::inherit()).output() {
|
||||||
Ok(status) => status,
|
Ok(status) => status,
|
||||||
|
|
|
@ -52,10 +52,8 @@ macro_rules! error {
|
||||||
macro_rules! trace_cmd {
|
macro_rules! trace_cmd {
|
||||||
($cmd:expr) => {
|
($cmd:expr) => {
|
||||||
{
|
{
|
||||||
#[allow(unused)]
|
|
||||||
use $crate::utils::exec::FormatShortCmd;
|
use $crate::utils::exec::FormatShortCmd;
|
||||||
|
|
||||||
#[cfg(feature = "tracing")]
|
|
||||||
::tracing::span!(
|
::tracing::span!(
|
||||||
target: "COMMAND",
|
target: "COMMAND",
|
||||||
::tracing::Level::TRACE,
|
::tracing::Level::TRACE,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue