instrumentation, log: add support for otel log collection.#663
Merged
Conversation
a79277f to
9ca5935
Compare
88d42a4 to
6efc5a8
Compare
42659c7 to
5d9f1a1
Compare
askervin
reviewed
Apr 17, 2026
44bc753 to
b164f8a
Compare
b164f8a to
4a3cd98
Compare
Collaborator
|
Sorry for delay, I will go through it tomorrow. |
Closed
kad
reviewed
Jun 18, 2026
kad
left a comment
Collaborator
There was a problem hiding this comment.
Let's rebase on top of current main, update deps and then it is lgtm from me.
There was a problem hiding this comment.
Pull request overview
This PR refactors the internal logging subsystem to use log/slog, adds structured logging support, and introduces OpenTelemetry log exporting (OTLP) with an accompanying e2e test and documentation/CRD updates.
Changes:
- Replace the legacy klog-based logging implementation with a
slog-based backend and handlers (including an OTEL bridge handler). - Add OpenTelemetry log exporting support under
instrumentation(OTLP HTTP/gRPC) and wire it into instrumentation startup. - Add an e2e test scenario + collector manifests for validating OTLP log collection; update docs and CRDs to expose new config fields.
Reviewed changes
Copilot reviewed 32 out of 34 changed files in this pull request and generated 18 comments.
Show a summary per file
| File | Description |
|---|---|
| test/e2e/policies.test-suite/topology-aware/n4c16/test40-otel-logging/otel-collector.yaml.in | Adds an OTEL collector deployment/config for log collection in e2e. |
| test/e2e/policies.test-suite/topology-aware/n4c16/test40-otel-logging/custom-config.yaml.in | Adds topology-aware test config enabling OTLP log export. |
| test/e2e/policies.test-suite/topology-aware/n4c16/test40-otel-logging/code.var.sh | Adds an e2e validation script that asserts CreateContainer logs are exported. |
| pkg/resmgr/cache/cache.go | Switches fatal logging to the formatted variant (Fatalf). |
| pkg/log/stdlog.go | Redirects log stdlib output through the new logger and uses Debugf. |
| pkg/log/slog.go | Introduces the new slog-backed logger implementation and text formatting handler. |
| pkg/log/slog-logger.go | Removes the previous slog bridge implementation. |
| pkg/log/signal.go | Removes the previous signal-based debug toggling implementation. |
| pkg/log/ratelimit.go | Removes the previous rate-limiting logger implementation. |
| pkg/log/ratelimit_test.go | Removes tests for the removed rate-limiter. |
| pkg/log/otel.go | Adds an OTEL handler indirection layer to dynamically attach/detach an OTEL slog handler. |
| pkg/log/logger.go | Defines the new Logger interface, levels, and attributes based on slog. |
| pkg/log/log.go | Removes the legacy logging backend implementation. |
| pkg/log/default.go | Updates the default logger initialization and flush behavior. |
| pkg/log/config.go | Reworks logging config parsing/state and debug toggling. |
| pkg/instrumentation/tracing/tracing.go | Updates semconv dependency version. |
| pkg/instrumentation/resource.go | Updates semconv dependency version. |
| pkg/instrumentation/logging/logging.go | Adds OTLP log exporting (OTEL log SDK + otelslog bridge). |
| pkg/instrumentation/instrumentation.go | Starts logging export as part of instrumentation startup. |
| pkg/apis/config/v1alpha1/instrumentation/zz_generated.deepcopy.go | Deep-copies the new LogExportPeriod field. |
| pkg/apis/config/v1alpha1/instrumentation/config.go | Adds new config fields for log exporting and kubebuilder markers. |
| go.mod | Adds OTEL log/otelslog deps and bumps OTEL + other module versions. |
| go.sum | Updates checksums for the new/bumped dependencies. |
| docs/resource-policy/setup.md | Documents debug config changes and OTEL log exporting setup. |
| deployment/helm/topology-aware/crds/config.nri_topologyawarepolicies.yaml | Exposes new instrumentation log fields in helm CRD schema. |
| deployment/helm/template/crds/config.nri_templatepolicies.yaml | Exposes new instrumentation log fields in helm CRD schema. |
| deployment/helm/balloons/crds/config.nri_balloonspolicies.yaml | Exposes new instrumentation log fields in helm CRD schema. |
| config/crd/bases/config.nri_topologyawarepolicies.yaml | Exposes new instrumentation log fields in base CRD schema. |
| config/crd/bases/config.nri_templatepolicies.yaml | Exposes new instrumentation log fields in base CRD schema. |
| config/crd/bases/config.nri_balloonspolicies.yaml | Exposes new instrumentation log fields in base CRD schema. |
| cmd/plugins/topology-aware/policy/topology-aware-policy.go | Updates a call site to use Infof rather than the removed Info. |
| cmd/plugins/topology-aware/main.go | Switches Fatal to Fatalf. |
| cmd/plugins/template/main.go | Switches Fatal to Fatalf. |
| cmd/plugins/balloons/main.go | Switches Fatal to Fatalf. |
Files not reviewed (1)
- pkg/apis/config/v1alpha1/instrumentation/zz_generated.deepcopy.go: Generated file
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+212
to
+226
| func (h *Handler) WithAttrs(attrs []Attr) slog.Handler { | ||
| n := &Handler{ | ||
| source: h.source, | ||
| } | ||
|
|
||
| if h.group == nil { | ||
| n.attrs = slices.Clone(h.attrs) | ||
| n.attrs = append(n.attrs, attrs...) | ||
| } else { | ||
| n.group = h.group.Clone() | ||
| n.group.attrs = slices.Clone(attrs) | ||
| } | ||
|
|
||
| return n | ||
| } |
Comment on lines
+303
to
+306
| func (h *Handler) FormatAttrs(buf *bytes.Buffer, r *slog.Record) { | ||
| prefix := "" | ||
| groups := []*group{} | ||
|
|
109858c to
33159d3
Compare
Signed-off-by: Ukri Niemimuukko <ukri.niemimuukko@intel.com>
Use log.Infof and log.Fatalf consistently everywhere for formatted logging. Signed-off-by: Krisztian Litkey <krisztian.litkey@intel.com>
Rework internal logger implementation using slog, allowing us to eventually move to structured logging. Signed-off-by: Krisztian Litkey <krisztian.litkey@intel.com>
Signed-off-by: Krisztian Litkey <krisztian.litkey@intel.com>
Signed-off-by: Krisztian Litkey <krisztian.litkey@intel.com>
Signed-off-by: Krisztian Litkey <krisztian.litkey@intel.com>
Add minimal documentation about Opentelemetry-based log exporting. Signed-off-by: Krisztian Litkey <krisztian.litkey@intel.com>
33159d3 to
c69731f
Compare
Collaborator
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.
Note: this PR is stacked on #664.
This patch series: