🚀 Feature: Add delay support to sink configuration#2040
🚀 Feature: Add delay support to sink configuration#2040letho1608 wants to merge 1 commit intorobusta-dev:masterfrom
Conversation
Extend the sink model to support delayed notification configuration. This will allow users to specify delays for when notifications should be sent to specific sinks. Affected files: sinks.py Signed-off-by: Le Quang Tho <92069270+letho1608@users.noreply.github.com>
WalkthroughA new module adds Pydantic models for sink notification delay configuration, introducing Changes
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~3 minutes 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ 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: 1
🧹 Nitpick comments (1)
src/robusta/core/model/sinks.py (1)
16-24: Consider renaming to avoid confusion with the existingSinkBaseParamsinsink_base_params.py.This is a new class in the model layer with different responsibilities than the existing
SinkBaseParamsinrobusta.core.sinks.sink_base_params.py. While they're in different modules and don't cause actual import conflicts, having two classes with the same name can be confusing for maintainers.Suggested alternatives:
SinkDelayConfigorSinkDelayParams(name reflects purpose)SinkConfigBase(distinguishes model config from sink implementation)- Keep the current name only if this is eventually intended to replace the existing
SinkBaseParams🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/robusta/core/model/sinks.py` around lines 16 - 24, The new model class named SinkBaseParams conflicts conceptually with the existing SinkBaseParams (class SinkBaseParams) in the sink implementation; rename the model class (e.g., to SinkDelayConfig or SinkDelayParams) and update all references to that class in the codebase (model consumers, type hints, imports, pydantic schemas) to use the new name, ensuring the class definition (previously "class SinkBaseParams(ActionParams):") is renamed and any places constructing or annotating with SinkBaseParams are updated to the chosen identifier and corresponding import paths; run tests/type checks after renaming to catch any remaining references.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@src/robusta/core/model/sinks.py`:
- Around line 10-13: The get_delay_seconds method currently ignores the
Optional[str] field condition, so any configured condition is not evaluated and
delays always apply; update get_delay_seconds to evaluate the condition (or
explicitly short-circuit) before returning delay_seconds—use the existing
condition field on the same model and return 0 (or None/skip) when the condition
does not evaluate to true for the given alert/context, or if you cannot
implement evaluation now add a clear TODO comment in get_delay_seconds noting
that condition must be evaluated and referencing the condition and delay_seconds
fields so future work implements expression parsing/execution.
---
Nitpick comments:
In `@src/robusta/core/model/sinks.py`:
- Around line 16-24: The new model class named SinkBaseParams conflicts
conceptually with the existing SinkBaseParams (class SinkBaseParams) in the sink
implementation; rename the model class (e.g., to SinkDelayConfig or
SinkDelayParams) and update all references to that class in the codebase (model
consumers, type hints, imports, pydantic schemas) to use the new name, ensuring
the class definition (previously "class SinkBaseParams(ActionParams):") is
renamed and any places constructing or annotating with SinkBaseParams are
updated to the chosen identifier and corresponding import paths; run tests/type
checks after renaming to catch any remaining references.
🪄 Autofix (Beta)
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
Run ID: 1e8af723-5650-4574-9add-4098d63023de
📒 Files selected for processing (1)
src/robusta/core/model/sinks.py
| :var condition: Optional condition that must be met for the delay to apply | ||
| """ | ||
| delay_seconds: int = Field(ge=0, description="Number of seconds to delay the notification") | ||
| condition: Optional[str] = Field(None, description="Optional condition for applying the delay") |
There was a problem hiding this comment.
The condition field is declared but not evaluated.
The condition field is defined here but get_delay_seconds() doesn't check it—delays will always apply regardless of any condition set. If this is intentional scaffolding for future implementation, consider adding a comment or TODO. Otherwise, users may set a condition expecting it to be honored.
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@src/robusta/core/model/sinks.py` around lines 10 - 13, The get_delay_seconds
method currently ignores the Optional[str] field condition, so any configured
condition is not evaluated and delays always apply; update get_delay_seconds to
evaluate the condition (or explicitly short-circuit) before returning
delay_seconds—use the existing condition field on the same model and return 0
(or None/skip) when the condition does not evaluate to true for the given
alert/context, or if you cannot implement evaluation now add a clear TODO
comment in get_delay_seconds noting that condition must be evaluated and
referencing the condition and delay_seconds fields so future work implements
expression parsing/execution.
🚀 New Feature
Problem
Extend the sink model to support delayed notification configuration. This will allow users to specify delays for when notifications should be sent to specific sinks.
Severity:
highFile:
src/robusta/core/model/sinks.pySolution
Add a new field like
notification_delay_secondsordelayed_notification_configto the sink configuration model. This should support both simple delays and more complex conditions.Changes
src/robusta/core/model/sinks.py(modified)Testing
Closes #1028