Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
Improve cache related trace logging. #4109
Improve cache related trace logging. #4109
Changes from all commits
45b19d3
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not too familiar with logrus internals, but I'm curious as to why this doesn't work in hooks?
It appears that the hooks get called before formatting the logs, within the same call to
.Log
. So surely to get the stack trace, you'd just need to call.String
within the hook (though if the hook does something like spawn a goroutine, I guess that confuses it)?If we can, I'd rather not add additional indentation for checks for
if logrus.GetLevel() == logrus.TraceLevel
: instead of doing that, we could preserve the spirit of the original by doing something like:There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we could use a hook like https://github.com/docker/buildx/blob/50fbdd86f928f9ed9c858e401783021264462077/commands/root.go#L47-L53
See https://github.com/docker/buildx/blob/50fbdd86f928f9ed9c858e401783021264462077/util/logutil/filter.go#L10-L38
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah my phrasing in the commit message wasn't super accurate, it's not hooks in and of themselves that are the problem but more that the hook has to be sure the field gets "unlazied" before passing it off to a separate goroutine despite all the values being of type
any
. That's possible but also just sort of a huge gotcha (which is my fault since I addedLazyStackTrace
, just trying to correct my own mistakes here 😅).E.g. the relevant line in Dagger is here. I think we'd need to either iterate over all the fields, doing a type assertion and calling
.String()
one-by-one, or do a full json marshal/unmarshal cycle every time.Either way, I think your suggestion of
func lazyStackTrace() string
is much better, I'll update to do that.