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

reload not working in tracing-subscriber v0.3.15 #2314

Open
cedricje opened this issue Sep 19, 2022 · 4 comments
Open

reload not working in tracing-subscriber v0.3.15 #2314

cedricje opened this issue Sep 19, 2022 · 4 comments

Comments

@cedricje
Copy link

cedricje commented Sep 19, 2022

Bug Report

Version

└── tracing-subscriber v0.3.15
    ├── tracing v0.1.36
    │   └── tracing-core v0.1.29
    ├── tracing-core v0.1.29 (*)
    └── tracing-log v0.1.3
        └── tracing-core v0.1.29 (*)

Platform

Linux LNMX-LPT005 5.4.0-125-generic #141-Ubuntu SMP Wed Aug 10 13:42:03 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux

Crates

tracing-subscriber and/or tracing_log

Description

When reloading a filter i don't see the log records that were enabled by the filter.
This started with version v0.3.15 of the tracing-subscriber crate, v0.3.14 works.
The features tracing-log and env-filter are enabled on the tracing-subscriber crate

This is an example:

use tracing_subscriber::EnvFilter;
use tracing_subscriber::{fmt, prelude::*, reload};

fn main() {
    let filter = EnvFilter::from_default_env();
    let (filter, reload_handle) = reload::Layer::new(filter);

    tracing_subscriber::registry()
        .with(filter)
        .with(fmt::Layer::default())
        .init();

    reload_handle.reload("info").unwrap();
    log::error!("error trace");
    log::info!("info trace");
}

When running this with tracing-subscriber v0.3.15, error trace is shown, but not info trace. WIth eg. version v0.3.14 it shows info trace.

@hawkw
Copy link
Member

hawkw commented Sep 19, 2022

Thanks for the report! My guess is that this is related to #2204, which is the only change between tracing-subscriber 0.3.14 and 0.3.15.

Do you know if this can be reproduced without actually reloading the reload layer? If the reload layer's filter is initially created with info enabled, and never reloaded, what events are shown?

@cedricje
Copy link
Author

If i remove reload_handle.reload("info").unwrap(); and run it with RUST_LOG=info to have the initial filter set to info, it shows the info traces.

Another thing i've noticed is when using tracing::info! isof log::info! it does show the info traces as expected.

@cedricje
Copy link
Author

From what i could see tracing_log::log_tracer::Builder::init calls log::set_maxlevel(LevelFilter::Error).
With the previous version of tracing-subscriber this was log::set_maxlevel(LevelFilter::Trace).

Should this be set to log::LevelFilter::max() and let log_tracer filter based on the level?

amokfa added a commit to bytebeamio/uplink that referenced this issue Feb 21, 2023
tekjar added a commit to bytebeamio/uplink that referenced this issue Feb 21, 2023
* feat: allow reloading tracing filter over http

* fix: add missing file from last commit

* doc: add tracing config print

* Make it compile

* Move tracing subscriber and api server from library to main

* Add uplinkctl

* pin tracing_subscriber

tokio-rs/tracing#2314

* Fix cargo lock file

---------

Co-authored-by: tekjar <raviteja@bytebeam.io>
Co-authored-by: bmcpt <iaansagar@gmail.com>
@jimmyH
Copy link

jimmyH commented Mar 14, 2024

Issue still exists on tracing-subscriber v0.3.18.

Looks like the maximum level is set when the tracing-subscriber is initialized and you can never increase it above this level when you reload ie if you initialize with Level::INFO you can decrease it with reload() but can never increase above Level::INFO.

Workaround:

  • Initialize with Level::TRACE
  • Then you can use reload() to dynamically change the trace level to whatever you want.

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

No branches or pull requests

3 participants