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

AddFailureIssueThreshold & RecoveryThreshold to MonitorConfig #775

Merged
merged 3 commits into from Apr 16, 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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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"`
cleptric marked this conversation as resolved.
Show resolved Hide resolved
}

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