cleanup(logs): migrate remaining klog.FromContext to klogutil.FromContext#1278
Merged
manusa merged 1 commit intoJul 10, 2026
Merged
Conversation
…text pkg/kubernetes/provider_gvk_filter.go was added in containers#1196 (target-specific tool filtering), which merged after the OTel logging work in containers#1260, so it kept calling klog.FromContext directly and is now the only production file that does. Switch it to klogutil.FromContext so AnyTargetHasGVKs warning logs carry the active trace span for log-trace correlation, and to restore the "no klog.FromContext in production code" invariant documented in AGENTS.md. Drops the now-unused k8s.io/klog/v2 import. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Signed-off-by: Marc Nuri <marc@marcnuri.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Description
pkg/kubernetes/provider_gvk_filter.gowas added in #1196 (target-specifictool filtering), which merged after the OpenTelemetry logging work in #1260.
As a result it kept calling
klog.FromContextdirectly, and it's now the onlyproduction file that does.
This migrates that single call site to
klogutil.FromContext, matching therest of the codebase, for two reasons:
klogutil.FromContextinjects the context into the logger's values so theOTel log bridge can extract the active trace span. With the old
klog.FromContext, theAnyTargetHasGVKswarning logs exported with notrace/span IDs and didn't correlate with the surrounding tool-call trace.
klog.FromContextdirectly in production code"invariant documented in
AGENTS.mdby feat(otel): logs are exported with otel now #1260.The
k8s.io/klog/v2import is dropped since this was its only use in the file.No behavior change beyond trace correlation;
go buildandgo vetare clean.