Skip to content

cleanup(logs): migrate remaining klog.FromContext to klogutil.FromContext#1278

Merged
manusa merged 1 commit into
containers:mainfrom
marcnuri-forks:cleanup/gvk-filter-klogutil
Jul 10, 2026
Merged

cleanup(logs): migrate remaining klog.FromContext to klogutil.FromContext#1278
manusa merged 1 commit into
containers:mainfrom
marcnuri-forks:cleanup/gvk-filter-klogutil

Conversation

@manusa

@manusa manusa commented Jul 10, 2026

Copy link
Copy Markdown
Member

Description

pkg/kubernetes/provider_gvk_filter.go was added in #1196 (target-specific
tool filtering), which merged after the OpenTelemetry logging work in #1260.
As a result it kept calling klog.FromContext directly, and it's now the only
production file that does.

This migrates that single call site to klogutil.FromContext, matching the
rest of the codebase, for two reasons:

  • klogutil.FromContext injects the context into the logger's values so the
    OTel log bridge can extract the active trace span. With the old
    klog.FromContext, the AnyTargetHasGVKs warning logs exported with no
    trace/span IDs and didn't correlate with the surrounding tool-call trace.
  • It restores the "do not use klog.FromContext directly in production code"
    invariant documented in AGENTS.md by feat(otel): logs are exported with otel now #1260.

The k8s.io/klog/v2 import is dropped since this was its only use in the file.
No behavior change beyond trace correlation; go build and go vet are clean.

…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>
@manusa manusa requested a review from Cali0707 as a code owner July 10, 2026 08:01
@manusa manusa added this to the 0.1.0 milestone Jul 10, 2026
@manusa manusa merged commit 7298077 into containers:main Jul 10, 2026
12 checks passed
@manusa manusa deleted the cleanup/gvk-filter-klogutil branch July 10, 2026 08:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant