Skip to content

Commit

Permalink
AddFailureIssueThreshold & RecoveryThreshold to MonitorConfig (#775)
Browse files Browse the repository at this point in the history
  • Loading branch information
cleptric committed Apr 16, 2024
1 parent bf970d1 commit 7954115
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 8 deletions.
4 changes: 4 additions & 0 deletions check_in.go
Expand Up @@ -87,6 +87,10 @@ type MonitorConfig struct { //nolint: maligned // prefer readability over optima
// A tz database string representing the timezone which the monitor's execution schedule is in.
// See: https://en.wikipedia.org/wiki/List_of_tz_database_time_zones
Timezone string `json:"timezone,omitempty"`
// The number of consecutive failed check-ins it takes before an issue is created.
FailureIssueThreshold int64 `json:"failure_issue_threshold,omitempty"`
// The number of consecutive OK check-ins it takes before an issue is resolved.
RecoveryThreshold int64 `json:"recovery_threshold,omitempty"`
}

type CheckIn struct { //nolint: maligned // prefer readability over optimal memory layout
Expand Down
20 changes: 12 additions & 8 deletions client_test.go
Expand Up @@ -383,10 +383,12 @@ func TestCaptureCheckIn(t *testing.T) {
Duration: time.Second * 10,
},
monitorConfig: &MonitorConfig{
Schedule: IntervalSchedule(1, MonitorScheduleUnitHour),
CheckInMargin: 10,
MaxRuntime: 5000,
Timezone: "Asia/Singapore",
Schedule: IntervalSchedule(1, MonitorScheduleUnitHour),
CheckInMargin: 10,
MaxRuntime: 5000,
Timezone: "Asia/Singapore",
FailureIssueThreshold: 5,
RecoveryThreshold: 10,
},
},
{
Expand All @@ -398,10 +400,12 @@ func TestCaptureCheckIn(t *testing.T) {
Duration: time.Second * 10,
},
monitorConfig: &MonitorConfig{
Schedule: CrontabSchedule("40 * * * *"),
CheckInMargin: 10,
MaxRuntime: 5000,
Timezone: "Asia/Singapore",
Schedule: CrontabSchedule("40 * * * *"),
CheckInMargin: 10,
MaxRuntime: 5000,
Timezone: "Asia/Singapore",
FailureIssueThreshold: 5,
RecoveryThreshold: 10,
},
},
}
Expand Down

0 comments on commit 7954115

Please sign in to comment.