Skip to content

chore: add missing shiftby in alert rule #6239

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Oct 23, 2024
Merged

Conversation

srikanthccv
Copy link
Member

@srikanthccv srikanthccv commented Oct 22, 2024

Summary

Part of #6151

Prior to this change, shift by happened only during the /query_range, making the alert created with shift by useless.


Important

Add shiftBy functionality to alert rules by implementing SetShiftByFromFunc() in BuilderQuery and applying it in query parsing and preparation.

  • Behavior:
    • Add SetShiftByFromFunc() method to BuilderQuery in v3.go to handle shiftBy functionality.
    • Apply SetShiftByFromFunc() in ParseQueryRangeParams in parser.go and prepareQueryRange in threshold_rule.go to set shiftBy during alert rule creation.
  • Tests:
    • Add test cases in parser_test.go and threshold_rule_test.go to verify shiftBy functionality for builder queries with timeShift function.
  • Misc:
    • Refactor ParseQueryRangeParams in parser.go to use SetShiftByFromFunc() for cleaner code.

This description was created by Ellipsis for ca5c756. It will automatically update as commits are pushed.

@github-actions github-actions bot added the chore label Oct 22, 2024
@srikanthccv srikanthccv changed the title chore: add missing shift in rule chore: add missing shiftby in alert rule Oct 23, 2024
@srikanthccv srikanthccv marked this pull request as ready for review October 23, 2024 04:37
Copy link
Contributor

@ellipsis-dev ellipsis-dev bot left a comment

Choose a reason for hiding this comment

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

👍 Looks good to me! Reviewed everything up to ca5c756 in 42 seconds

More details
  • Looked at 259 lines of code in 5 files
  • Skipped 0 files when reviewing.
  • Skipped posting 2 drafted comments based on config settings.
1. pkg/query-service/model/v3/v3.go:793
  • Draft comment:
    Consider adding a check for an empty Args list in SetShiftByFromFunc to prevent potential panics. Log an error if Args is empty, as this is an unexpected state.
  • Reason this comment was not posted:
    Decided after close inspection that this draft comment was likely wrong and/or not actionable:
    The function already checks for the length of Args before accessing it, so there is no risk of a panic. The suggestion to log an error if Args is empty is more about logging unexpected states rather than preventing a panic. This could be considered a code quality improvement, but it's not strictly necessary for functionality.
    I might be underestimating the importance of logging unexpected states for debugging purposes. Logging could help in identifying issues during runtime that are not immediately apparent.
    While logging unexpected states can be useful, the absence of such logging does not constitute a functional issue. The current implementation prevents panics, which is the primary concern.
    The comment suggests a code quality improvement by logging unexpected states, but it is not necessary for functionality. The function already prevents panics by checking the length of Args.
2. pkg/query-service/app/parser.go:1145
  • Draft comment:
    Avoid using the component/index.tsx file structure approach, as it makes it difficult to debug and find components using global search tools like VS Code.
  • Reason this comment was not posted:
    Comment was on unchanged code.

Workflow ID: wflow_FeDb6yhV4gFprvG9


You can customize Ellipsis with 👍 / 👎 feedback, review rules, user-specific overrides, quiet mode, and more.

@srikanthccv srikanthccv enabled auto-merge (squash) October 23, 2024 04:39
Copy link
Member

@shivanshuraj1333 shivanshuraj1333 left a comment

Choose a reason for hiding this comment

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

lgtm

@srikanthccv srikanthccv merged commit 6c7167a into develop Oct 23, 2024
16 checks passed
@srikanthccv srikanthccv deleted the missing-shift-rule branch October 24, 2024 02:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants