You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Rollup merge of #135391 - jieyouxu:conditional-tracing, r=onur-ozkan
bootstrap: Implement conditional `tracing` infra
Add a conditional `tracing` setup that is gated behind `BOOTSTRAP_TRACING` env var. This `tracing` infra is implemented by:
- Introducing an optional `tracing` cargo feature in bootstrap.
- Added optional `tracing*` dependencies which are gated behind the `tracing` cargo feature.
- When `BOOTSTRAP_TRACING` is set, `bootstrap.py` will build bootstrap with `--features=tracing`.
There is a small trick here to share `BOOTSTRAP_TRACING` env var without having to add a separate env var:
- `BOOTSTRAP_TRACING=1` is not a registered `tracing` filter target, so that can be used to enable the `tracing` cargo feature yet not actually enable any tracing logs (useful for editor r-a setups without actually outputting any tracing logs).
- `BOOTSTRAP_TRACING=TRACE` and such are actually valid `tracing` filters, but that sets `BOOTSTRAP_TRACING` anyway.
Example usage: #135299 (that experimental PR is not conditionally gated)
This PR is intentionally kept minimal to focus on the infra itself. To get actual mileage, instrumentations will need to be added to individual `Step`s and such.
r? `@onur-ozkan` (or reroll)
[^experimental]: This shows what's *possible* with the infra in an experimental implementation.
26
+
27
+
The env var `BOOTSTRAP_TRACING` accepts a [`tracing` env-filter][tracing-env-filter]. The `TRACE` filter will enable *all*`trace` level or less verbose level tracing output.
- Gate it behind `trace` level for fine-granularity, possibly `debug` level for core functions.
73
+
- Explicitly pick an instrumentation name via `name = ".."` to distinguish between e.g. `run` of different steps.
74
+
- Take care to not cause diverging behavior via tracing, e.g. building extra things only when tracing infra is enabled.
75
+
76
+
### Enabling `tracing` bootstrap feature in rust-analyzer
77
+
78
+
You can adjust your `settings.json`'s `rust-analyzer.check.overrideCommand` and `rust-analyzer.cargo.buildScripts.overrideCommand` if you want to also enable `logging` cargo feature by default in your editor. This is mostly useful if you want proper r-a completions and such when working on bootstrap itself.
79
+
80
+
```json
81
+
"rust-analyzer.check.overrideCommand": [
82
+
"BOOTSTRAP_TRACING=1", // <- BOOTSTRAP_TRACING=1 won't enable tracing filter, but it will activate bootstrap's `tracing` feature
0 commit comments