feat(log): emit build-started JSON message with run_id - #16632
Conversation
|
r? @epage rustbot has assigned @epage. Use Why was this reviewer chosen?The reviewer was selected based on:
|
|
Until a better solution is out, I think this is sufficient for your use case (with some extra probe to |
|
So, for my use-case with rustwide, it doesn't help :( Because If the writing into CARGO_HOME ever became performed default, I guess this would also currently break crater 😆 |
|
I think we have a few options here:
The second one is less ambiguous and straightforward to implement, though I am not sure if that meets your use case |
|
It would work for the Docker/container use-case, and making the log dir be configurable sounds like a good idea regardless. (streaming to stdout would also be appreciated, but I guess that can wait until there's more design work done on -Zbuild-analysis) |
|
i am in roughly the same boat as @Kobzol here. a configurable log dir is necessary for my use case. |
|
Useful for rust-lang/crater#825 |
|
Created #16696 for specifying log file paths. |
This comment has been minimized.
This comment has been minimized.
|
Just noting that I wanted to do a benchmark for #8545 and measure only the duration of building the build script itself, for which |
|
For the large-scale rustwide experiment, yeah. But now I don't even know how to run a one-off measurement to get the build script duration, other than eyeballing the HTML timings page or patching Cargo. |
This comment has been minimized.
This comment has been minimized.
Noting that this has also been happening to the handful of people doing performance evaluations to enable the new solver and polonius alpha on nightly. This PR would still be useful for people to analyze these experiments' results and have per-dependency stats instead of the coarse grained full crate graph results. An alternative is ofc to parse the HTML from For my own experiments, strictly speaking I'm in the same boat as Jakub, doing crater-like rustwide experiments, and thus would also need #16696, so it's fine. |
This test documents the current behavior when using both `-Zbuild-analysis` and `--message-format=json`.
When both `-Zbuild-analysis` and `--message-format=json` are enabled,
emit a `build-started` JSON message to stdout containing the `run_id`.
This allows external tools to associate the JSON output stream
with the corresponding log file in `~/.cargo/log/{run_id}.jsonl`.
While a better design of JSON message and structured logging is needed,
this provides a temporary workaround for those needing the old
`--timings=json` flag
Closes rust-lang#16576
|
This PR was rebased onto a different master commit. Here's a range-diff highlighting what actually changed. Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers. |
|
Would you mind taking a look at this? I think even without #16696, this is useful standalone and help do analysis locally. At least better than parsing HTML. The message is behind (See #16632 (comment)) |
|
The re-review of this will definitely be a blocker before stabilization. |
|
Can you call out an item for this in the tracking issue? |
Done. Thanks! |
Update cargo submodule 14 commits in c79e8f89441b3e73d6d65d125c0c745792808c74..b07e5a08651da80108eb65d7dc769ee04589f9bf 2026-08-04 19:17:33 +0000 to 2026-08-07 21:51:16 +0000 - feat(profile): Add built-in profile debug (rust-lang/cargo#17214) - feat(toml): allow overriding inherited default-features in 2024 (rust-lang/cargo#17126) - feat(resolver): Report the min-publish-age in the lock message (rust-lang/cargo#17328) - refactor(resolver): resolve() does not need an optional gctx (rust-lang/cargo#17331) - fix(resolver): Make min-publish-age relative to --publish-time (rust-lang/cargo#17327) - test(trim-paths): exercise unremap files with debuggers (rust-lang/cargo#17326) - feat(log): emit build-started JSON message with run_id (rust-lang/cargo#16632) - docs: remove stray `directory` metavar from `cargo update --breaking` option (rust-lang/cargo#17319) - fix(lock): Use more accurate 'highest, rather than 'latest' (rust-lang/cargo#17317) - docs(changelog): Pull the --verbose item (rust-lang/cargo#17315) - revert(compiler): forward verbose flag to rustc for local crates (rust-lang/cargo#17314) - fix(diag): Gate blanket_hint_mostly_unused with -Zprofile-hint-mostly-unused (rust-lang/cargo#17313) - fix(diag): Remove complexity, perf, and nursery lint groups (rust-lang/cargo#17307) - fix(git): Avoid use of git's core.fsmonitor (rust-lang/cargo#17306) r? ghost
Update cargo submodule 14 commits in c79e8f89441b3e73d6d65d125c0c745792808c74..b07e5a08651da80108eb65d7dc769ee04589f9bf 2026-08-04 19:17:33 +0000 to 2026-08-07 21:51:16 +0000 - feat(profile): Add built-in profile debug (rust-lang/cargo#17214) - feat(toml): allow overriding inherited default-features in 2024 (rust-lang/cargo#17126) - feat(resolver): Report the min-publish-age in the lock message (rust-lang/cargo#17328) - refactor(resolver): resolve() does not need an optional gctx (rust-lang/cargo#17331) - fix(resolver): Make min-publish-age relative to --publish-time (rust-lang/cargo#17327) - test(trim-paths): exercise unremap files with debuggers (rust-lang/cargo#17326) - feat(log): emit build-started JSON message with run_id (rust-lang/cargo#16632) - docs: remove stray `directory` metavar from `cargo update --breaking` option (rust-lang/cargo#17319) - fix(lock): Use more accurate 'highest, rather than 'latest' (rust-lang/cargo#17317) - docs(changelog): Pull the --verbose item (rust-lang/cargo#17315) - revert(compiler): forward verbose flag to rustc for local crates (rust-lang/cargo#17314) - fix(diag): Gate blanket_hint_mostly_unused with -Zprofile-hint-mostly-unused (rust-lang/cargo#17313) - fix(diag): Remove complexity, perf, and nursery lint groups (rust-lang/cargo#17307) - fix(git): Avoid use of git's core.fsmonitor (rust-lang/cargo#17306) r? ghost
What does this PR try to resolve?
When both
-Zbuild-analysisand--message-format=jsonare enabled,emit a
build-startedJSON message to stdout containing therun_id.This allows external tools to associate the JSON output stream
with the corresponding log file in
~/.cargo/log/{run_id}.jsonl.While a better design of JSON message and structured logging is needed,
this provides a temporary workaround for those needing the old
--timings=jsonflag.Closes #16576
How to test and review this PR?
Commit by commit.