-
Notifications
You must be signed in to change notification settings - Fork 3.4k
operator: Attach context to logs when available #39728
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
Conversation
/test |
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.
@HadrienPatte thanks for the PR. The migration to slog is not fully completed. Can we wait until all of these PRs are merged https://github.com/cilium/cilium/pulls?q=is%3Aopen+is%3Apr+author%3Aaanm+label%3Afeature%2Fslog before this one?
I'm planning to create one more PR besides the ones already created and after that the slog migration is done.
Thanks!
Sure no problem 👍 |
cba49fd
to
808e4f2
Compare
808e4f2
to
0a0e680
Compare
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.
Thanks! ✅
@aanm @HadrienPatte are there any implications on the v1.18 release to either include or exclude this PR? If this is important for the slog migration then we might want to track it as a release blocker and add the |
I don't think we need this PR in 1.18 as it's only bringing context logging to a small subset of the repository, a couple more followup PR will be necessary to cover the whole repo |
/test |
Since the migration to `slog`, it is possible to attach contexts to logs. This is recommended by the [`slog` docs](https://pkg.go.dev/log/slog#hdr-Contexts): > It is recommended to pass a context to an output method if one is available. This allows things like trace IDs to be extracted from contexts and attached to logs, allowing log/trace correlation. This PR uses the `XxxContext()` `slog` methods when a `context.Context` is available in packages under `operator/`. Signed-off-by: Hadrien Patte <hadrien.patte@datadoghq.com>
0a0e680
to
1aa29e5
Compare
/test |
Since the migration to
slog
, it is possible to attach contexts to logs. This is recommended by theslog
docs:This allows things like trace IDs to be extracted from contexts and attached to logs, allowing log/trace correlation.
This PR uses the
XxxContext()
slog
methods when acontext.Context
is available in packages underoperator/
.Please ensure your pull request adheres to the following guidelines:
description and a
Fixes: #XXX
line if the commit addresses a particularGitHub issue.
Fixes: <commit-id>
tag, thenplease add the commit author[s] as reviewer[s] to this issue.