Repository navigation
feat(go): add gated OTLP metrics, reconcile events, and log bridge (#2148) - #2675
MartinForReal wants to merge 1 commit into
Conversation
fcb707f to
2ff253f
Compare
2ff253f to
8fa258e
Compare
|
Hi @supreme-gg-gg, friendly ping for review when you have a moment. This is the gated Go observability work for #2148 (OTLP metrics, reconcile Events, controller log to OTLP bridge). I have rebased it on latest main and resolved the conflicts, so it is ready for another look. Thanks! |
8fa258e to
457af0a
Compare
457af0a to
f2a65d5
Compare
|
Addressed: the adk-side OTLP token metric that duplicated #2673 was removed entirely (go/adk/pkg/telemetry/metrics.go and its hooks/tests are gone from this branch). The PR now stays focused on the controller-scoped OTLP metrics, reconcile events, and the controller log bridge; the GenAI token metric lives only in #2673. |
|
This pull request has been marked as stale because of no activity in the last 15 days. It will be closed in the next 5 days unless it is tagged "no stalebot" or other activity occurs. |
eb2faad to
672bfbf
Compare
672bfbf to
ea259fa
Compare
Refs: kagent-dev#2148 Signed-off-by: Shangxiang Fan (from Dev Box) <shafan@microsoft.com>
ea259fa to
969629e
Compare
Implements the Go-side observability gaps from #2148 as three independent, default-OFF additions so the Go runtime/controller expose the same OpenTelemetry signals as the Python runtime.
1. Go ADK — GenAI token-usage metrics (
go/adk)Configures a MeterProvider with a periodic OTLP metric exporter and emits
gen_ai.client.token.usage(Int64 histogram, unit{token}) per LLM call.gen_ai.token.type(input/output),gen_ai.request.model,gen_ai.response.model,gen_ai.provider.name,gen_ai.agent.name.Partialevents so chunked streams are not double-counted.config_usage.ModelName); response model falls back to the request model.OTEL_METRICS_ENABLED(default OFF) and the standardOTEL_EXPORTER_OTLP_*endpoint/protocol resolution shared with traces.adk/pkg/telemetry/metrics_test.go(recording via ManualReader, provider-name mapping) andadk/pkg/a2a/executor_metrics_test.go(token accounting + partial/nil guard).2. Kubernetes Events on reconcile (
go/core)The discovery reconcilers surface lifecycle events via an optional
EventRecorder, mirroring the agentharness-substrate-controller pattern:internal/controller/remotemcpserver):Normal ToolsDiscovered,Warning ValidationFailed,Warning ReconcileFailed.internal/controller/mcpserver):Normal ToolsDiscovered,Warning ValidationFailed,Warning ReconcileFailed.Note on Agent/ModelConfig: in current
mainthose objects reconcile through the KRT-based status collections ingo/core/v2/controller, not classic controller-runtimeReconcileinstallers, so they have no EventRecorder path to attach events to. The events gap is therefore implemented on the two remaining classic discovery controllers — the direct successors of the MCPServerTool/RemoteMCPServer roles named in the issue. Emission is a no-op when no recorder is wired (the default).3. Controller log → OTLP bridge (
go/core)telemetry.InitLoggerProviderbuilds an OTLP LoggerProvider viaautoexport(same resource attributes as traces) and sets it global.telemetry.ControllerZapOptsadditively tees the controller zap logger with anotelzapbridge core, preserving stdout.cmd/controller-v2/main.gobefore the controller logger is built.OTEL_LOGGING_ENABLED(already plumbed via the Helm chartotel.logging.enabled); when unset both functions are no-ops and logs are byte-identical.Validation
go build ./...,go veton all changed packages,gofmt/goimports clean.go testpasses foradk/pkg/a2a,adk/pkg/telemetry,adk/pkg/config,core/internal/telemetry, andcore/internal/controller/{mcpserver,remotemcpserver}(incl. the new event tests).pkg/sessionhas two pre-existing Windows-only TempDir-cleanup failures (SQLite handle held open during cleanup); unrelated to this change.Dependencies
Promotes
otlplog,otlpmetric(grpc/http),otel/log,otel/metric,otel/sdk/metricto direct requires at the same versions already in the graph, and addsgo.opentelemetry.io/contrib/bridges/otelzap v0.19.0. No version bumps.Refs: #2148