Skip to content
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

(Sentinel) reduce spamming from dal checks, offsetchecks, and event checks #2236

Merged
merged 2 commits into from
Aug 27, 2024

Conversation

nick-bisonai
Copy link
Collaborator

@nick-bisonai nick-bisonai commented Aug 27, 2024

Description

Alarm per pair will be sent with 10 times of offset,
for less occurrences, it'll send cnt message for previous offset

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

Checklist before requesting a review

  • I have performed a self-review of my code.
  • If it is a core feature, I have added thorough tests.

Deployment

  • Should publish npm package
  • Should publish Docker image

@nick-bisonai nick-bisonai self-assigned this Aug 27, 2024
Copy link
Contributor

coderabbitai bot commented Aug 27, 2024

Walkthrough

Walkthrough

The changes involve updating alarm handling logic across multiple files, introducing new constants AlarmOffsetPerPair and AlarmOffsetInTotal, and modifying functions to improve the tracking and reporting of delays related to WebSocket and Data Access Layer operations. The alterations include enhanced counting mechanisms and streamlined alerting processes to provide more granular control over system performance monitoring.

Changes

Files Change Summary
node/pkg/checker/dal/app.go, node/pkg/checker/dal/app_test.go, node/pkg/checker/dal/types.go Introduced new constants for alarm offsets, updated alarm counting logic, and modified test expectations for alarm counts in TestExtractWsAlarms.
node/pkg/checker/event/app.go Replaced existing constant with new alarm offsets, streamlined feed delay checking and reporting logic, and consolidated alerting mechanisms within the checkFeeds function.
node/pkg/checker/offset/app.go Added new constants to define thresholds for local and global offset alarms, modified offset checking logic to track delays, and improved alerting for local and global aggregate offsets.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant AlarmSystem
    participant WebSocket
    participant DAL

    User->>AlarmSystem: Trigger Check
    AlarmSystem->>WebSocket: Check Last Update Offsets
    WebSocket->>AlarmSystem: Return Delay Info
    AlarmSystem->>DAL: Check DAL Delays
    DAL->>AlarmSystem: Return DAL Delay Info
    AlarmSystem->>User: Send Alarm Summary
Loading

🐇 In the meadow, where bunnies play,
New constants hop in, brightening the day.
With alarms now clearer, we cheer and rejoice,
For tracking our delays, we’ve made a wise choice!
So let’s munch on carrots, and dance with glee,
For the code is now better, as happy as can be! 🥕✨


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share
Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@nick-bisonai nick-bisonai marked this pull request as ready for review August 27, 2024 05:26
@nick-bisonai nick-bisonai requested a review from a team as a code owner August 27, 2024 05:26
Copy link
Contributor

@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: 0

Outside diff range, codebase verification and nitpick comments (1)
node/pkg/checker/event/app.go (1)

306-313: Consolidate AlarmOffsetPerPair definition.

The constant AlarmOffsetPerPair is defined multiple times across different files with the same value. To ensure maintainability and consistency, consider consolidating its definition to a single location and importing it where needed.

  • Defined in:
    • node/pkg/checker/event/app.go
    • node/pkg/checker/offset/app.go
    • node/pkg/checker/dal/types.go
Analysis chain

Updated alarm thresholds.

The alarm thresholds are updated to use AlarmOffsetPerPair. This change enhances the granularity of alarm reporting. Ensure that this constant is correctly defined and used consistently throughout the codebase.

Verify the definitions and usage of AlarmOffsetPerPair in the codebase.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the definitions and usage of `AlarmOffsetPerPair`.

# Test: Search for the definitions of the constants. Expect: Definitions in the appropriate files.
rg --type go 'const AlarmOffsetPerPair' -A 2

# Test: Search for the usage of the constants. Expect: Consistent usage throughout the codebase.
rg --type go 'AlarmOffsetPerPair'

Length of output: 1045

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 7e77f89 and 8c30acb.

Files selected for processing (5)
  • node/pkg/checker/dal/app.go (4 hunks)
  • node/pkg/checker/dal/app_test.go (1 hunks)
  • node/pkg/checker/dal/types.go (1 hunks)
  • node/pkg/checker/event/app.go (3 hunks)
  • node/pkg/checker/offset/app.go (7 hunks)
Additional comments not posted (19)
node/pkg/checker/dal/types.go (2)

12-12: LGTM!

The constant AlarmOffsetPerPair is correctly declared.

The code changes are approved.


13-13: LGTM!

The constant AlarmOffsetInTotal is correctly declared.

The code changes are approved.

node/pkg/checker/dal/app_test.go (2)

38-38: LGTM!

The value for "BTC" in alarmCountMap has been correctly updated to 10.

The code changes are approved.


39-39: LGTM!

The value for "ETH" in alarmCountMap has been correctly updated to 10.

The code changes are approved.

node/pkg/checker/offset/app.go (5)

23-23: LGTM!

The constant AlarmOffsetPerPair is correctly declared.

The code changes are approved.


24-24: LGTM!

The constant AlarmOffsetInTotal is correctly declared.

The code changes are approved.


93-93: LGTM!

The variable localAggregateAlarmCount is correctly declared and initialized.

The code changes are approved.


94-94: LGTM!

The variable globalAggregateAlarmCount is correctly declared and initialized.

The code changes are approved.


Line range hint 136-193: LGTM!

The function checkOffsets is correctly implemented. It includes logic to increment alarm counts based on delay and generate messages accordingly.

The code changes are approved.

node/pkg/checker/dal/app.go (7)

32-32: Introduction of websocketNotPushedCount.

The new variable websocketNotPushedCount is introduced to track the number of symbols for which the WebSocket has not been pushed. This improves the granularity of alarm reporting.

The code changes are approved.


50-52: Summary message for WebSocket not being pushed.

If any symbols have not been pushed, a summary message is appended to the messages slice. This provides a clear and concise summary of the issue.

The code changes are approved.


156-156: Introduction of totalDelayed.

The new variable totalDelayed is introduced to track the number of delayed price updates. This improves the granularity of alarm reporting.

The code changes are approved.


186-188: Summary message for delayed price updates.

If any symbols have delayed price updates, a summary message is appended to the msg string. This provides a clear and concise summary of the issue.

The code changes are approved.


38-43: Updated alarm thresholds.

The alarm thresholds are updated to use AlarmOffsetPerPair and AlarmOffsetInTotal. This change enhances the granularity of alarm reporting. Ensure that these constants are correctly defined and used consistently throughout the codebase.

Verify the definitions and usage of AlarmOffsetPerPair and AlarmOffsetInTotal in the codebase.

Verification successful

Constants are consistently defined and used.

The constants AlarmOffsetPerPair and AlarmOffsetInTotal are consistently defined and used across the codebase with the same values. This confirms the update enhances the granularity of alarm reporting as intended. No further action is needed.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the definitions and usage of `AlarmOffsetPerPair` and `AlarmOffsetInTotal`.

# Test: Search for the definitions of the constants. Expect: Definitions in the appropriate files.
rg --type go 'const AlarmOffsetPerPair' -A 2
rg --type go 'const AlarmOffsetInTotal' -A 2

# Test: Search for the usage of the constants. Expect: Consistent usage throughout the codebase.
rg --type go 'AlarmOffsetPerPair'
rg --type go 'AlarmOffsetInTotal'

Length of output: 1941


240-240: Updated alarm thresholds.

The alarm thresholds are updated to use AlarmOffsetPerPair. This change enhances the granularity of alarm reporting. Ensure that this constant is correctly defined and used consistently throughout the codebase.

Verify the definitions and usage of AlarmOffsetPerPair in the codebase.

Verification successful

Consistent definition and usage of AlarmOffsetPerPair.

The constant AlarmOffsetPerPair is consistently defined and used across the codebase with a value of 10. This ensures uniform alarm threshold behavior across different modules. No issues found.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the definitions and usage of `AlarmOffsetPerPair`.

# Test: Search for the definitions of the constants. Expect: Definitions in the appropriate files.
rg --type go 'const AlarmOffsetPerPair' -A 2

# Test: Search for the usage of the constants. Expect: Consistent usage throughout the codebase.
rg --type go 'AlarmOffsetPerPair'

Length of output: 1045


174-178: Updated alarm thresholds.

The alarm thresholds are updated to use AlarmOffsetPerPair and AlarmOffsetInTotal. This change enhances the granularity of alarm reporting. Ensure that these constants are correctly defined and used consistently throughout the codebase.

Verify the definitions and usage of AlarmOffsetPerPair and AlarmOffsetInTotal in the codebase.

Verification successful

Alarm thresholds are consistently defined and used.

The constants AlarmOffsetPerPair and AlarmOffsetInTotal are correctly defined and consistently used throughout the codebase, enhancing the granularity of alarm reporting as intended.

  • Defined in node/pkg/checker/event/app.go and node/pkg/checker/dal/types.go.
  • Used in node/pkg/checker/dal/app.go, node/pkg/checker/offset/app.go, and node/pkg/checker/event/app.go.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the definitions and usage of `AlarmOffsetPerPair` and `AlarmOffsetInTotal`.

# Test: Search for the definitions of the constants. Expect: Definitions in the appropriate files.
rg --type go 'const AlarmOffsetPerPair' -A 2
rg --type go 'const AlarmOffsetInTotal' -A 2

# Test: Search for the usage of the constants. Expect: Consistent usage throughout the codebase.
rg --type go 'AlarmOffsetPerPair'
rg --type go 'AlarmOffsetInTotal'

Length of output: 1941

node/pkg/checker/event/app.go (3)

148-148: Introduction of totalDelayed.

The new variable totalDelayed is introduced to track the number of delayed feeds. This improves the granularity of alarm reporting.

The code changes are approved.


170-171: Summary message for delayed feeds.

If any feeds are delayed, a summary message is appended to the msg string. This provides a clear and concise summary of the issue.

The code changes are approved.


157-167: Updated alarm thresholds.

The alarm thresholds are updated to use AlarmOffsetPerPair and AlarmOffsetInTotal. This change enhances the granularity of alarm reporting. Ensure that these constants are correctly defined and used consistently throughout the codebase.

Verify the definitions and usage of AlarmOffsetPerPair and AlarmOffsetInTotal in the codebase.

Verification successful

Verification Successful: Consistent Definitions and Usage of Alarm Thresholds

The constants AlarmOffsetPerPair and AlarmOffsetInTotal are consistently defined and used across the codebase. They are defined with the same values in multiple files and are applied uniformly in various parts of the code. No discrepancies were found.

  • AlarmOffsetPerPair is defined with a value of 10.
  • AlarmOffsetInTotal is defined with a value of 3.

These constants are used in node/pkg/checker/event/app.go, node/pkg/checker/dal/app.go, and node/pkg/checker/offset/app.go.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the definitions and usage of `AlarmOffsetPerPair` and `AlarmOffsetInTotal`.

# Test: Search for the definitions of the constants. Expect: Definitions in the appropriate files.
rg --type go 'const AlarmOffsetPerPair' -A 2
rg --type go 'const AlarmOffsetInTotal' -A 2

# Test: Search for the usage of the constants. Expect: Consistent usage throughout the codebase.
rg --type go 'AlarmOffsetPerPair'
rg --type go 'AlarmOffsetInTotal'

Length of output: 1941

Copy link
Contributor

@Intizar-T Intizar-T left a comment

Choose a reason for hiding this comment

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

lgtm!

@nick-bisonai nick-bisonai merged commit cb690d1 into master Aug 27, 2024
1 check passed
@nick-bisonai nick-bisonai deleted the feat/reduce-sentinel-spamming branch August 27, 2024 05:43
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.

2 participants