-
-
Notifications
You must be signed in to change notification settings - Fork 318
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
gix-trace: tracing level set by subscriber not always respected #1615
Comments
Thanks a lot for letting me know! This is indeed unexpected and unintended, and from all I know that shouldn't be possible. It feels a bit like… codepaths that are encountered before the parent application sets the tracing level see the default, which might be DEBUG, and use it from that point on. That would explain why after setting the application level to DEBUG, even more traces show up. Maybe that can also be explained with the tracing-subscriber being 'cached' in spans, along with its settings. Assuming that the application truly sets up its tracing as the first thing the application does, I'd expect no issues. |
Hmm I'll have to review my code as well, perhaps I am doing something to cause this. The only thing that runs before setting up the subscriber is clap, but I have some custom value parsers that may actually be causing an issue now that you mention it. |
No its not my parser. I temporarily disabled them just to test, but its still exhibiting the same behavior. I suppose I should add this is with the latest stable crate, as well. |
After spending a bit of time trying to triage this, I am also confused. I see that, when tracing is enabled, you simply reuse the tracing levels from upstream tracing_core, which should respect the set level in the subscriber. In fact, if the subscriber had not been set, the messages wouldn't even show at all (which I confirmed). But somehow the message prints at an inappropriate level, it could be this is an upstream bug in tracing core itself, or perhaps gix unintentially ignores and/or resets the tracing level somewhere? Still trying to see if I can find out... edit |
Okay so I'm not sure the linked issue is actually relevant, at least according to the information in the post. My tracing-core version in my lockfile is the v0.1.32, which is the version the OP mentioned did not exhibit this issue. In order to debug this further, and because I was curious if perhaps the custom tracing macros in gitoxide were to blame, I did a quick and dirty swap for the call to Sure enough, using the upstream tracing macro correctly respects the set global subscriber level in my app. So the issue seems to be lying somewhere in |
Thanks a lot for digging into this! That makes sense, probably there is some issue with the way the macro is implemented then.
The idea here was to have macros purpose-made for how I usually use these tracing capabilities. But even more important, these macros compile to nothing if tracing is disabled, so the |
I took a look and couldn't find a reason for the level not being respected. Maybe it's even more subtle somehow. |
I was wondering if perhaps the no-op implementation here had something to do with it: |
That looks like an interesting lead! Maybe a correct implementation has to implement this as the subscriber might tell it to simply never interact with it. I think the reason this custom call-site implementation even exists is that when the crate was created, it was not possible to use the If not, maybe one has to copy more of the implementation in order to be more correct. |
So I took a crack at using the Just wanted to see if it would even help though, still not sure. |
This fix is temporary while I investigate upstream: GitoxideLabs#1615
Until we find a resolution for GitoxideLabs/gitoxide#1615
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:
If I leave my app at the default level (WARN), then I still get the following DEBUG output on the cli:
However, if I increase the verbosity level to DEBUG I get:
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.
The text was updated successfully, but these errors were encountered: