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

Reenable tracing and change the log level of existing instrument tracing to trace #2117

Closed
bfops opened this issue Jan 13, 2025 · 1 comment · Fixed by #2144
Closed

Reenable tracing and change the log level of existing instrument tracing to trace #2117

bfops opened this issue Jan 13, 2025 · 1 comment · Fixed by #2144

Comments

@bfops
Copy link
Collaborator

bfops commented Jan 13, 2025

Problem

We log mostly via the log crate.
We use the tracing and tracing-subscriber crates to configure logging.
For performance reasons, however, tracing is disabled statically for release builds in the public workspace.
As a consequence, any log configuration such as level filters does not apply anymore to log-emitted records -- that is, if one runs an executable with RUST_LOG=trace set, all log records will be output.

This is not great, because it undermines nuanced log configuration within the private workspace.
For example, one might want to temporarily enable debug logging for a particular span (i.e. code path), without opening the floodgates of emitting all debug logs.

Proposed Solution

  • Configure tracing in the public workspace to use features = ["release_max_level_info"] by default
  • Change all #[instrument] annotations in the public workspace to use level = "trace" by default
    • We may later selectively raise the level of interesting spans created like this
  • Revise (default) log configuration for the private workspace (config.toml)
  • Confirm that hot-reloading of the log configuration still works (it seems it might not)
  • Optional: standardize on tracing instead of log, i.e. replace log::info!, log::debug! etc. with their tracing counterparts. tracing's support for "structured logging" (kv pairs) is invaluable in practice.
@kim
Copy link
Contributor

kim commented Jan 14, 2025

Some more investigation reveals that setting features = ["release_max_level_*"] in the public workspace will completely prevent tracing from working in the private workspace.

We should set this feature only in the Cargo.toml of binary crates.

kim added a commit that referenced this issue Jan 20, 2025
Disabling tracing (`features = ["release_max_level_off"]`) at the
workspace level prevents library users from using tracing at all.
Instead, set the feature for each binary individually.

Also change all but one `#[instrument]` macros to be at "trace" level,
which will prevent code gen unless the static level is at trace. This is
because most of them were introduced for `tracy` tracing, and may be at
"hot" code locations.

Fixes: #2117
@kim kim closed this as completed in #2144 Jan 22, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants