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) DAL rest network delay checker #2326

Merged
merged 3 commits into from
Nov 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions node/pkg/checker/dal/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,11 +109,12 @@ func Start(ctx context.Context) error {
}
defer pool.Close()

networkDelayAlarmCount := 0
alarmCount := map[string]int{}
wsDelayAlarmCount := map[string]int{}

for range ticker.C {
err := checkDal(endpoint, key, alarmCount)
err := checkDal(endpoint, key, alarmCount, &networkDelayAlarmCount)
if err != nil {
log.Error().Str("Player", "DalChecker").Err(err).Msg("error in checkDal")
}
Expand All @@ -136,7 +137,7 @@ func buildSubscriptionParams(configs []Config) []string {
return params
}

func checkDal(endpoint string, key string, alarmCount map[string]int) error {
func checkDal(endpoint string, key string, alarmCount map[string]int, networkDelayAlarmCount *int) error {
msg := ""

now := time.Now()
Expand All @@ -147,6 +148,16 @@ func checkDal(endpoint string, key string, alarmCount map[string]int) error {
)
networkDelay := time.Since(now)

if networkDelay > NetworkDelayThreshold {
*networkDelayAlarmCount++
if *networkDelayAlarmCount > AlarmOffsetInTotal {
msg += fmt.Sprintf("(DAL) network delay: %s\n", networkDelay)
*networkDelayAlarmCount = 0
}
} else {
*networkDelayAlarmCount = 0
}

if err != nil {
return err
}
Expand Down
1 change: 1 addition & 0 deletions node/pkg/checker/dal/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ const (
AlarmOffsetInTotal = 3
WsDelayThreshold = 9 * time.Second
WsPushThreshold = 5 * time.Second
NetworkDelayThreshold = 6 * time.Second
IgnoreKeys = "test,sentinel,orakl_reporter"

TrafficCheckQuery = `select count(1) from rest_calls where
Expand Down