Skip to content

🚀 Feature: Add delay support to sink configuration#2040

Open
letho1608 wants to merge 1 commit intorobusta-dev:masterfrom
letho1608:contribai/feat/add-delay-support-to-sink-configuration
Open

🚀 Feature: Add delay support to sink configuration#2040
letho1608 wants to merge 1 commit intorobusta-dev:masterfrom
letho1608:contribai/feat/add-delay-support-to-sink-configuration

Conversation

@letho1608
Copy link
Copy Markdown

🚀 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: high
File: src/robusta/core/model/sinks.py

Solution

Add a new field like notification_delay_seconds or delayed_notification_config to the sink configuration model. This should support both simple delays and more complex conditions.

Changes

  • src/robusta/core/model/sinks.py (modified)

Testing

  • Existing tests pass
  • Manual review completed
  • No new warnings/errors introduced

Closes #1028

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>
@CLAassistant
Copy link
Copy Markdown

CLAassistant commented Mar 28, 2026

CLA assistant check
All committers have signed the CLA.

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Mar 28, 2026

Walkthrough

A new module adds Pydantic models for sink notification delay configuration, introducing DelayedNotificationConfig with delay duration and optional condition field, and SinkBaseParams base class extending ActionParams with notification delay configuration and a method to compute effective delay duration.

Changes

Cohort / File(s) Summary
Delayed Notification Configuration Models
src/robusta/core/model/sinks.py
Added DelayedNotificationConfig model with delay_seconds (non-negative integer) and optional condition field. Added SinkBaseParams base class with name, notification_delay_seconds, and delayed_notification_config fields. Implemented get_delay_seconds() method to resolve effective delay from delayed_notification_config or notification_delay_seconds.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly indicates a feature for delay support in sink configuration, which matches the primary objective of implementing delayed notification functionality.
Description check ✅ Passed The description explains the problem, solution, and changes related to adding delay support to sink configuration, which is directly relevant to the changeset.
Linked Issues check ✅ Passed The PR implements delayed notification configuration to enable notification chains where sinks can be notified after specified delays, directly addressing issue #1028's requirement for delayed promotion of alerts to subsequent receivers.
Out of Scope Changes check ✅ Passed All changes are focused on adding delay support to sink configuration models, which is within the scope of the linked issue requirements.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (1)
src/robusta/core/model/sinks.py (1)

16-24: Consider renaming to avoid confusion with the existing SinkBaseParams in sink_base_params.py.

This is a new class in the model layer with different responsibilities than the existing SinkBaseParams in robusta.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:

  • SinkDelayConfig or SinkDelayParams (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

📥 Commits

Reviewing files that changed from the base of the PR and between 14d6ba5 and 8104b5a.

📒 Files selected for processing (1)
  • src/robusta/core/model/sinks.py

Comment on lines +10 to +13
: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")
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ability to send notification after some additional pause

2 participants