-
-
Notifications
You must be signed in to change notification settings - Fork 296
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
[feat] Add a request ID and include it in log lines #1476
[feat] Add a request ID and include it in log lines #1476
Conversation
57d62d5
to
6df84cf
Compare
Despite the fact that the request ID is now set on the If the |
So golang-ci lint is a little unhappy with us due to the context changes I guess. I'm not super convinced it's rightfully complaining about all cases though: internal/media/cron.go:49:13: Non-inherited new context, use function like `context.WithXXX` instead (contextcheck)
log.Error(nil, err)
^
internal/media/processingmedia.go:251:33: Function `decodeVideoFrame->decodeVideoFrame$1` should pass the context parameter (contextcheck)
video, err := decodeVideoFrame(rc)
^
internal/media/prune.go:89:14: Non-inherited new context, use function like `context.WithXXX` instead (contextcheck)
if err := f(context.Background()); err != nil {
^
internal/typeutils/astointernal.go:85:12: Non-inherited new context, use function like `context.WithXXX` instead (contextcheck)
log.Infof(nil, "error extracting account emojis: %s", err)
^
internal/typeutils/astointernal.go:260:43: Function `extractAttachments` should pass the context parameter (contextcheck)
status.Attachments = c.extractAttachments(statusable)
^
internal/config/validate.go:58:13: SA1012: do not pass a nil Context, even if a function permits it; pass context.TODO if you are unsure about which Context to use (staticcheck)
log.Warnf(nil, "%s was set to 'http'; this should *only* be used for debugging and tests!", ProtocolFlag())
^
internal/cache/util.go:38:13: SA1012: do not pass a nil Context, even if a function permits it; pass context.TODO if you are unsure about which Context to use (staticcheck)
log.Panicf(nil, "failed %s after %d tries", msg, count)
^
internal/concurrency/workers.go:69:12: SA1012: do not pass a nil Context, even if a function permits it; pass context.TODO if you are unsure about which Context to use (staticcheck)
log.Infof(nil, "%s created with workers=%d queue=%d", |
Thanks to the awesome help of @NyaaaWhatsUpDoc this is now ready to go! Ish. Once we figure out what to do about the lint thing. |
Definitely best to disable that linter imo. It's been annoying me for a while :p |
2225eb0
to
1c40679
Compare
Weird extra thing, the following lint warnings are bogus:
Neither of those two functions take a context in their signature. |
I'm OK with dropping the contextcheck linter altogether in a separate PR, afaik it hasn't found any actual hits yet, only false positives. Anyway, reviewing this now :) |
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.
looking good so far :)
532da81
to
a22a5a1
Compare
The history is a bit messy now and you can't really roll back any individual commit so probably best to squash-merge this |
we always do, don't worry :) |
we love squerges |
381cff9
to
4d3a646
Compare
I smashed the history to make this easier to rebase. The only way I could find to retain @NyaaaWhatsUpDoc's authorship was the |
This adds a lightweight form of tracing to GTS. Each incoming request is assigned a Request ID which we then pass on and log in all our log lines. Any function that gets called downstream from an HTTP handler should now emit a requestID=value pair whenever it logs something. Co-authored-by: kim <grufwub@gmail.com>
4d3a646
to
5e2f9b6
Compare
I rebased this on main, should be good to go with 0.7.0 being out. |
Merged, thank you! :) |
This updates the middleware log.WithField calls that create new loggers to include the context the first time around. Without it the requestID does not get logged. Fixup from superseriousbusiness#1476
This updates the middleware log.WithField calls that create new loggers to include the context the first time around. Without it the requestID does not get logged. Fixup from #1476
In superseriousbusiness#1476 we updated log.WithFields() but we forgot about log.WithField(). Also updates a few explicit log.Entry{} creations.
In #1476 we updated log.WithFields() but we forgot about log.WithField(). Also updates a few explicit log.Entry{} creations.
Description
This adds the necessary code to:
log
call so we can log it along with anything elseChecklist
Please put an x inside each checkbox to indicate that you've read and followed it:
[ ]
->[x]
If this is a documentation change, only the first checkbox must be filled (you can delete the others if you want).
go fmt ./...
andgolangci-lint run
.