Repository navigation
feat(agent,registrar): export component logs to the otel-collector over OTLP - #222
Merged
Merged
Conversation
…er OTLP The agent and registrar only logged zap JSON to stderr (kubectl logs); their application logs weren't queryable in VictoriaLogs alongside the proxy access logs, metrics, and traces that already flow through the collector. Add an OTel LoggerProvider + OTLP gRPC log exporter, tee'd into the existing zap core via the otelzap bridge, so records go to BOTH stderr (unchanged) and OTLP -> collector -> VictoriaLogs. No collector change is needed: the existing logs pipeline (otlp receiver -> victorialogs) is reused. - common/telemetry: new SetupLogs (mirrors SetupTracing), reusing newResource so logs carry the same service.name/version + env resource attrs as metrics/traces. - common/log: NewLoggerWithCore tees an extra zapcore.Core into the stderr core. - common/manager: new SetupManagerLogging wires the provider + otelzap core when --logs-enabled and an OTLP endpoint are set; returns a flush-on-exit shutdown. Plain SetupLogging is kept for the proxy supervisor (different config shape). - agent/registrar root: PersistentPreRunE + a deferred final log flush. - charts: telemetry.logs.enabled flag (default off) for both charts; add OTEL_RESOURCE_ATTRIBUTES (k8s.node/pod/namespace) so logs are filterable per node/pod in VictoriaLogs. This also closes a gap: the agent container had no resource attrs, so its own metrics/traces now carry node identity too. - Bump agent chart 0.2.4->0.2.5, registrar 0.2.0->0.2.1. Component logs land in VictoriaLogs under service.name=aether-agent / aether-registrar (vs access logs which use log_name=aether_access_logs). Tradeoff: logs before OTel init / during a hard crash aren't exported (still on stderr); trace correlation is partial (only log calls carrying a span context). Co-Authored-By: Claude Opus 4.8 <[email protected]> Claude-Session: https://claude.ai/code/session_01Pihqn5RmVPhV9HTdBnqbvY
bpalermo
added a commit
that referenced
this pull request
Jun 18, 2026
…ace correlation (#223) logr's sink API is context-free, so a log line cannot see the active span — the reason #222's OTLP logs carry no trace correlation. Move the agent, registrar, CNI server and registry logging to stdlib log/slog, whose Handle(ctx, record) is context-aware: the otelslog bridge now populates trace_id/span_id natively on the OTLP LogRecord from the ctx passed to the *Context log methods. Foundation (common/log, common/manager): - common/log builds *slog.Logger over a fanout handler: stderr JSON (timestamp/ level/logger/caller/message parity with the old zap output) + an optional extra handler (otelslog), each gated by a shared level. Named() replaces WithName; V(n) collapses to slog Debug. - common/manager.SetupManagerLogging returns a *slog.Logger and wires the otelslog OTLP handler when --logs-enabled is set. controller-runtime is logr-only, so it rides logr.FromSlogHandler over the same handler — one output pipeline. - common/telemetry.SetupLogs is reused; only the bridge changes (otelzap -> otelslog). Components: every logr.Logger field/param becomes *slog.Logger. Calls use the ...Context(ctx, ...) variants wherever a ctx is in scope (handlers, traced funcs) so spanned operations carry trace_id; ctx-less sites (background goroutines, constructors) use the plain methods. logr.Error(err, msg, kv) -> slog Error(msg, "error", err, kv). Holdouts kept on logr (no spans, use the controller-runtime global logger): common/file and the cni-install binary (bridged to the same slog handler). The CNI plugin keeps its own separate zap logging stack. Drops the otelzap dependency added in #222. Claude-Session: https://claude.ai/code/session_01Pihqn5RmVPhV9HTdBnqbvY Co-authored-by: Claude Opus 4.8 <[email protected]>
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.
What
The agent and registrar only emitted zap JSON to stderr (
kubectl logs); their application logs weren't queryable in VictoriaLogs alongside the proxy access logs, metrics, and traces that already flow through the collector. This adds in-process OTLP log export for both components.No collector change — the existing
logspipeline (otlpreceiver →otlphttp/victorialogs, the same one the proxy access logs use) is reused.Changes
common/telemetry: newSetupLogs(mirrorsSetupTracing), reusingnewResourceso logs carry the sameservice.name/version+ env resource attrs as metrics/traces. Newlogs_test.go.common/log:NewLoggerWithCoretees an extrazapcore.Coreinto the stderr core.common/manager: newSetupManagerLoggingbuilds the LoggerProvider + otelzap core when--logs-enabledand an OTLP endpoint are set; returns a flush-on-exit shutdown. PlainSetupLoggingis kept for the proxy supervisor (different config shape).PersistentPreRunE+ a deferred final log flush.telemetry.logs.enabledflag (default off) for both charts; addOTEL_RESOURCE_ATTRIBUTES(k8s.node/pod/namespace) so logs are filterable per node/pod. This also closes a gap — the agent container had no resource attrs, so its own metrics/traces now carry node identity too (consistent with the proxy's fix(telemetry): per-node identity for static infra cluster stats (agent_xds) #210 attrs).0.2.4→0.2.5, registrar0.2.0→0.2.1.Result
Component logs land in VictoriaLogs under
service.name=aether-agent/aether-registrar(vs access logs which uselog_name=aether_access_logs), so they're cleanly distinguishable.Tradeoffs (accepted)
kubectl logs).Test
bazel build //agent/... //registrar/... //common/... //charts/...green.bazel test //common/... //agent/internal/cmd/... //registrar/internal/cmd/... //charts/...pass (incl. newlogs_test.go).helm templatewithtelemetry.logs.enabled=truerenders--logs-enabled=true+OTEL_RESOURCE_ATTRIBUTESon both; absent when disabled.Post-merge validation plan: deploy to talos-main with
--set telemetry.logs.enabled=trueand confirmservice.name=aether-agent/aether-registrarstreams appear in VictoriaLogs via the grafana MCP, withkubectl logsunchanged.🤖 Generated with Claude Code