feat(recipe): let components declare the Prometheus metrics they read #3450
All Vouch review confidence checks passed
Residual risk 0.20 = Change Risk (0.50) × (1 − Review Confidence (0.60)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.50 · 600 lines diff across 7 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size
diff_size
0.383
Shallow Review Depth
shallow_review_depth
0.289
Real PR Conversation Timeline
1 comments
"Review active on #3450"
general
weight: 0.35
yuanchen8911
Summary
Adds the ADR-026 runtime metrics contract to the registry: a component declares the data it queries from the runtime Prometheus server (
telemetry.promql:monitorsFrom+ RE2series), the server declares the value paths the bundler owns (telemetry.promqlServer), and every bundle path (CLI,aicrd,Client.BundleComponents) writes the union of enabled consumers' declarations into the enabled server's values.Motivation / Context
Implements the PromQL scrape-scope piece of ADR-026 (NKTP telemetry), so the runtime Prometheus scrapes only the namespaces and series its consumers declared.
Fixes: #3443
Related: #3445
Type of Change
Component(s) Affected
cmd/aicr,pkg/cli)cmd/aicrd,pkg/server)pkg/recipe)pkg/bundler,pkg/component)pkg/collector,pkg/snapshotter)pkg/validator)pkg/errors,pkg/k8s)docs/,examples/)pkg/client/v1)Implementation Notes
monitorsFromnamespaces, monitor selectors matching every monitor (matchExpressions: [], since the chart treats an empty map as unset), and one default scrape class keeping only the declared series.INVALID_REQUESTwhen amonitorsFromcomponent is absent or disabled, more than one server is enabled, the server's values already set an owned path, or--set/--set-json/--set-file/--dynamictargets one. A pattern that does not compile, on its own or inside its group, fails the registry load.spec.scrapeClass; the bundler can't check this because operators create some monitors at run time. Documented inrecipe-development.md.telemetryyet; this lands the contract and the injection only.Testing
-race, and lint reports 0 issues.make qualifypasses, with 86.2% total coverage against the 83% floor.- each failure mode;
- each pattern's flags staying in that pattern, so
(?i)fooplusBARdoesn't matchbar;- a pattern with an unterminated
\Q, rejected at registry load;- monitor selectors written as match-all, with an override of them rejected;
-
--set,--set-json,--set-file, and--dynamicon owned paths rejected;- a
--splitset carrying the scope in the server's class only;- identical values from
Makeand the SDK;- a disabled server, which gets nothing injected and nothing checked.
{matchExpressions: []}renders as match-all, while an empty map falls back to the chart's release-label selector. A test against the real chart comes with #3445, where kube-prometheus-stack declares the server.| Package | Coverage before | Coverage after |
|---|---|---|
|
pkg/recipe| 91.1% | 91.2% ||
pkg/bundler| 88.2% | 88.6% ||
pkg/client/v1| 86.6% | 86.6% ||
pkg/recipe/recipetest(new) | — | 82.8% |Risk Assessment
Rollout notes: Inert until a registry entry declares
telemetry.promqlServer; no existing recipe changes output.Checklist
make testwith-race)make lint)git commit -s -S) — GPG signing info