Description
Current behavior 😯
So typically crates that implement or integrate with the tracing
crate are meant to respect whatever the user set tracing level is at application start time. At a high-level, I have a cli application that sets the tracing level early in main. I also having the tracing feature enabled in gix, which is a dependency of my app.
As far as I can tell gix does not respect the default level set, at least in places. It is a bit strange actually because if I leave the default level (which is WARN in my app) I still get a few DEBUG
level messages from gix, but if I set the level explicitly to DEBUG, I get more DEBUG level traces from gix components than I did before.
This essentially leads me to believe that some parts of gix are respecting the current tracing level and others are not.
Expected behavior 🤔
All tracing operations should uniformly respect the currently set level as set by the subscriber.
Git behavior
Not directly equivalent since we are talking about a rust specific tracing framework here, but git tries to maintain the correct verbosity level as set by the user, as far as I understand it.
Steps to reproduce 🕹
I first noticed this behavior when using a network client to fetch and update HEAD like so:
let mut remote = repo
.find_remote(remote_str.as_str())
.map_err(Box::new)?
.with_fetch_tags(Tags::None);
remote
.replace_refspecs(Some("+HEAD"), Direction::Fetch)
.map_err(Box::new)?;
let client = remote.connect(Direction::Fetch).map_err(Box::new)?;
let sync = client
.prepare_fetch(Discard, Options::default())
.map_err(Box::new)?;
let outcome = sync
.receive(Discard, &AtomicBool::new(false))
.map_err(Box::new)?;
If I leave my app at the default level (WARN), then I still get the following DEBUG output on the cli:
DEBUG remote::Connection::ref_map():remote::Connection::fetch_refs(): gix_credentials::program: launching credential helper cmd="/bin/sh" "-c" "/nix/store/ci5hgcdq8jmqzh1vn4p3wab22pqnvfjj-gh-2.53.0/bin/gh auth git-credential \"$@\"" "--" "get"
DEBUG remote::Connection::ref_map():remote::Connection::fetch_refs(): gix_credentials::program: launching credential helper cmd="/bin/sh" "-c" "/nix/store/ci5hgcdq8jmqzh1vn4p3wab22pqnvfjj-gh-2.53.0/bin/gh auth git-credential \"$@\"" "--" "store"
However, if I increase the verbosity level to DEBUG I get:
DEBUG reqwest::connect: starting new connection: https://github.com/
DEBUG resolve{host=github.com}: hyper_util::client::legacy::connect::dns: resolving host="github.com"
DEBUG hyper_util::client::legacy::connect::http: connecting to 140.82.112.3:443
DEBUG hyper_util::client::legacy::connect::http: connected to 140.82.112.3:443
DEBUG h2::client: binding client connection
DEBUG h2::client: client connection bound
DEBUG h2::codec::framed_write: send frame=Settings { flags: (0x0), enable_push: 0, initial_window_size: 2097152, max_frame_size: 16384, max_header_list_size: 16384 }
DEBUG hyper_util::client::legacy::pool: pooling idle connection for ("https", github.com)
DEBUG Connection{peer=Client}: h2::codec::framed_write: send frame=WindowUpdate { stream_id: StreamId(0), size_increment: 5177345 }
DEBUG Connection{peer=Client}: h2::codec::framed_write: send frame=Headers { stream_id: StreamId(1), flags: (0x5: END_HEADERS | END_STREAM) }
DEBUG Connection{peer=Client}: h2::codec::framed_read: received frame=Settings { flags: (0x0), max_concurrent_streams: 100, initial_window_size: 67108864, max_frame_size: 68608, enable_connect_protocol: 1 }
DEBUG Connection{peer=Client}: h2::codec::framed_write: send frame=Settings { flags: (0x1: ACK) }
DEBUG Connection{peer=Client}: h2::codec::framed_read: received frame=Settings { flags: (0x1: ACK) }
DEBUG Connection{peer=Client}: h2::proto::settings: received settings ACK; applying Settings { flags: (0x0), enable_push: 0, initial_window_size: 2097152, max_frame_size: 16384, max_header_list_size: 16384 }
DEBUG Connection{peer=Client}: h2::codec::framed_read: received frame=Headers { stream_id: StreamId(1), flags: (0x4: END_HEADERS) }
DEBUG Connection{peer=Client}: h2::codec::framed_read: received frame=Data { stream_id: StreamId(1), flags: (0x1: END_STREAM) }
DEBUG remote::Connection::ref_map():remote::Connection::fetch_refs(): gix_credentials::program: launching credential helper cmd="/bin/sh" "-c" "/nix/store/ci5hgcdq8jmqzh1vn4p3wab22pqnvfjj-gh-2.53.0/bin/gh auth git-credential \"$@\"" "--" "get"
DEBUG hyper_util::client::legacy::pool: reuse idle connection for ("https", github.com)
DEBUG Connection{peer=Client}: h2::codec::framed_write: send frame=Headers { stream_id: StreamId(3), flags: (0x5: END_HEADERS | END_STREAM) }
DEBUG Connection{peer=Client}: h2::codec::framed_read: received frame=Headers { stream_id: StreamId(3), flags: (0x4: END_HEADERS) }
DEBUG Connection{peer=Client}: h2::codec::framed_read: received frame=Data { stream_id: StreamId(3) }
DEBUG Connection{peer=Client}: h2::codec::framed_read: received frame=Data { stream_id: StreamId(3) }
DEBUG Connection{peer=Client}: h2::codec::framed_read: received frame=Data { stream_id: StreamId(3) }
DEBUG Connection{peer=Client}: h2::codec::framed_read: received frame=Data { stream_id: StreamId(3) }
DEBUG Connection{peer=Client}: h2::codec::framed_read: received frame=Data { stream_id: StreamId(3) }
DEBUG Connection{peer=Client}: h2::codec::framed_read: received frame=Data { stream_id: StreamId(3), flags: (0x1: END_STREAM) }
DEBUG remote::Connection::ref_map():remote::Connection::fetch_refs(): gix_credentials::program: launching credential helper cmd="/bin/sh" "-c" "/nix/store/ci5hgcdq8jmqzh1vn4p3wab22pqnvfjj-gh-2.53.0/bin/gh auth git-credential \"$@\"" "--" "store"
DEBUG hyper_util::client::legacy::pool: reuse idle connection for ("https", github.com)
DEBUG Connection{peer=Client}: h2::codec::framed_write: send frame=Headers { stream_id: StreamId(5), flags: (0x4: END_HEADERS) }
DEBUG Connection{peer=Client}: h2::codec::framed_write: send frame=Data { stream_id: StreamId(5), flags: (0x1: END_STREAM) }
DEBUG Connection{peer=Client}: h2::codec::framed_read: received frame=WindowUpdate { stream_id: StreamId(5), size_increment: 107 }
DEBUG Connection{peer=Client}: h2::codec::framed_read: received frame=WindowUpdate { stream_id: StreamId(0), size_increment: 2147418219 }
DEBUG Connection{peer=Client}: h2::codec::framed_read: received frame=Headers { stream_id: StreamId(5), flags: (0x4: END_HEADERS) }
DEBUG Connection{peer=Client}: h2::codec::framed_read: received frame=Data { stream_id: StreamId(5) }
DEBUG Connection{peer=Client}: h2::codec::framed_read: received frame=Data { stream_id: StreamId(5), flags: (0x1: END_STREAM) }
So it is possibly a single call site that is the issue. I will attempt to triage later myself when I have the time, but this is as much as I know so far.