feat(telemetry): extend TelemetryPolicy with logging stanza - #2179
feat(telemetry): extend TelemetryPolicy with logging stanza#2179andresllh wants to merge 2 commits into
Conversation
Add a logging stanza to TelemetryPolicy enabling configurable audit field enrichment for auth decision logs. The reconciler passes logging field bindings through the existing domain-agnostic wasm metadata pipeline, producing io.kuadrant.logging.fields filter metadata that Authorino consumes to enrich log output. - Add LoggingSpec/LoggingConfig types with fields map - Add KuadrantLoggingBinding helper and KuadrantLoggingPrefix constant - Extend reconcileSpec to iterate logging fields via AddDataTo - Regenerate deepcopy and CRD manifests - Add unit tests for binding functions, domain routing, and reconciler Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> Signed-off-by: Andres Llausas <allausas@redhat.com>
|
Warning Review limit reached
Next review available in: 4 minutes You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (5)
📝 WalkthroughWalkthrough
ChangesTelemetry logging support
Estimated code review effort: 3 (Moderate) | ~20 minutes Possibly related PRs
Suggested reviewers: Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🧹 Nitpick comments (1)
cmd/extensions/telemetry-policy/internal/controller/telemetrypolicy_reconciler_test.go (1)
173-179: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winAssert the error status contents.
The test only checks that
statusis non-nil. It also passes ifreconcileSpecreturns an enforced or otherwise incorrect status together withexpectedErr.Inspect
calculateErrorStatusand assert the expected condition status, reason, and observed generation.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@cmd/extensions/telemetry-policy/internal/controller/telemetrypolicy_reconciler_test.go` around lines 173 - 179, Strengthen the test around reconcileSpec by validating the returned error status contents rather than only checking that status is non-nil. Use calculateErrorStatus as the expected shape and assert the condition status, reason, and observed generation match the expected values while preserving the existing error assertion.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@cmd/extensions/telemetry-policy/api/v1alpha1/telemetrypolicy_types.go`:
- Around line 93-97: The TelemetryPolicy Fields map currently allows keys
containing periods that are later misinterpreted as nested logging paths. Update
the API validation for Fields keys to reject periods at admission, preserving
literal field-name behavior; regenerate the extension API DeepCopy output with
make generate, and add a regression test covering a key such as request.user.id.
- Around line 49-54: The optional Metrics and Logging fields in the telemetry
policy type must be pointers so omitempty removes them when unset. Update
reconcileSpec to safely handle nil Metrics and Logging values, then run make
generate and add a serialization test confirming a targetRef-only policy omits
both fields.
---
Nitpick comments:
In
`@cmd/extensions/telemetry-policy/internal/controller/telemetrypolicy_reconciler_test.go`:
- Around line 173-179: Strengthen the test around reconcileSpec by validating
the returned error status contents rather than only checking that status is
non-nil. Use calculateErrorStatus as the expected shape and assert the condition
status, reason, and observed generation match the expected values while
preserving the existing error assertion.
🪄 Autofix
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 1b95df7c-2a1d-4ef0-a3c0-65742be71906
📒 Files selected for processing (8)
cmd/extensions/telemetry-policy/api/v1alpha1/telemetrypolicy_types.gocmd/extensions/telemetry-policy/api/v1alpha1/zz_generated.deepcopy.gocmd/extensions/telemetry-policy/config/crd/bases/extensions.kuadrant.io_telemetrypolicies.yamlcmd/extensions/telemetry-policy/internal/controller/telemetrypolicy_reconciler.gocmd/extensions/telemetry-policy/internal/controller/telemetrypolicy_reconciler_test.gointernal/wasm/action_spec_test.gopkg/extension/types/types.gopkg/extension/types/types_test.go
…in field names Address CodeRabbit review feedback: - Change Metrics and Logging to pointer types so omitempty correctly omits them when unset, preventing CRD validation errors from Go clients - Add nil guards in reconcileSpec for both optional specs - Add CEL validation rule on LoggingConfig.Fields to reject period- containing keys that would be misrouted by DomainAndFieldName - Regenerate deepcopy and CRD manifests Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> Signed-off-by: Andres Llausas <allausas@redhat.com>
Summary
loggingstanza (logging.default.fields) for configurable audit field enrichment on auth decision logsKuadrantLoggingBindinghelper andKuadrantLoggingPrefixconstant in the extension types packageAddDataTo, routing them through the existing domain-agnostic wasm metadata pipeline asio.kuadrant.logging.fieldsfilter metadatabuildMetadataContextdomain routing with mixed metrics/logging domains, and reconciler behavior (logging-only, mixed, error propagation, empty spec)Example TelemetryPolicy
Consumer
The companion Authorino PR (Kuadrant/authorino#671) reads
io.kuadrant.logging.fieldsfrom CheckRequest filter metadata and appends the resolved fields to auth decision log output.Test plan
KuadrantLoggingBinding/KuadrantMetricBindingunit tests passbuildMetadataContextcorrectly groupslogging.fieldsbindings underio.kuadrant.logging.fieldsmetadata keybuildMetadataContextcorrectly separates mixedmetrics.labelsandlogging.fieldsbindings into distinct sorted entriesDomainAndFieldNamesplitslogging.fields.client_identity→ domain=logging.fields, field=client_identityAddDataTowith correct domain, binding name, and expressionAddDataToerrors correctlymake generateandmake extensions-manifestsproduce no diff (generated files are current)go vetclean,go fmtcleango test -tags unit ./...— all new tests pass; 4 pre-existing OIDC failures unrelated🤖 Generated with Claude Code
Summary by CodeRabbit