Conversation
Signed-off-by: Yakir Oren <yakiroren@gmail.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughAdded pprof profiling scopes: wrapped per-handler event dispatch and third-party tracer reporting in Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 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: 1
🧹 Nitpick comments (1)
pkg/rulemanager/rule_manager.go (1)
233-235: Thread the caller's profiling context into these paths instead of starting from context.Background().The
pprof.Docalls at lines 233-235 and 361-363 usecontext.Background(), which replaces the outer"event"label scope already established by the caller inpkg/containerwatcher/v2/event_handler_factory.go(lines 200-212). Preserve label composition by deriving the rule scope from the caller's profiling context rather than creating a new one fromcontext.Background().🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@pkg/rulemanager/rule_manager.go` around lines 233 - 235, Replace the use of context.Background() in the pprof.Do calls with the profiling context passed down from the caller so labels are composed rather than replaced; specifically, where pprof.Do(context.Background(), pprof.Labels("rule", rule.ID), func(_ context.Context) { shouldAlert, err = rm.celEvaluator.EvaluateRule(enrichedEvent, rule.Expressions.RuleExpression) }) is used, thread the incoming context (the function's ctx/eventCtx) into pprof.Do instead of context.Background() and propagate that same ctx into the closure so the outer "event" labels remain composed with the "rule" label.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@pkg/rulemanager/rule_manager.go`:
- Around line 230-235: The code is evaluating rule.Expressions.RuleExpression
instead of the already-filtered ruleExpressions, which can run CEL against
unrelated expressions; inside the pprof.Do block where
rm.celEvaluator.EvaluateRule is called (with enrichedEvent), pass the filtered
variable ruleExpressions instead of rule.Expressions.RuleExpression so
EvaluateRule uses the same filtered expressions as EvaluatePolicyRulesForEvent.
---
Nitpick comments:
In `@pkg/rulemanager/rule_manager.go`:
- Around line 233-235: Replace the use of context.Background() in the pprof.Do
calls with the profiling context passed down from the caller so labels are
composed rather than replaced; specifically, where
pprof.Do(context.Background(), pprof.Labels("rule", rule.ID), func(_
context.Context) { shouldAlert, err =
rm.celEvaluator.EvaluateRule(enrichedEvent, rule.Expressions.RuleExpression) })
is used, thread the incoming context (the function's ctx/eventCtx) into pprof.Do
instead of context.Background() and propagate that same ctx into the closure so
the outer "event" labels remain composed with the "rule" label.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: cd791834-8b1e-4da9-836f-f60c8790bd62
📒 Files selected for processing (2)
pkg/containerwatcher/v2/event_handler_factory.gopkg/rulemanager/rule_manager.go
Summary by CodeRabbit