Skip to content

Commit

Permalink
feature(checker): Log triggers with critical time of check (#987)
Browse files Browse the repository at this point in the history
  • Loading branch information
Tetrergeru authored Feb 15, 2024
1 parent 9dd518e commit 1dd7c8b
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 0 deletions.
1 change: 1 addition & 0 deletions checker/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ type Config struct {
LogTriggersToLevel map[string]string
MetricEventPopBatchSize int64
MetricEventPopDelay time.Duration
CriticalTimeOfCheck time.Duration
}

// SourceCheckConfig represents check parameters for a single metric source
Expand Down
10 changes: 10 additions & 0 deletions checker/worker/trigger_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,16 @@ func (manager *WorkerManager) handleTriggerInLock(triggerID string, metrics *met
defer metrics.TriggersCheckTime.UpdateSince(startedAt)

err = manager.checkTrigger(triggerID)

timeSince := time.Since(startedAt)
if timeSince > manager.Config.CriticalTimeOfCheck {
manager.Logger.Warning().
String("trigger_id", triggerID).
Error(err).
String("time_of_check", timeSince.String()).
Msg("It took too long to check trigger")
}

return err
}

Expand Down
4 changes: 4 additions & 0 deletions cmd/checker/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ type checkerConfig struct {
MetricEventPopBatchSize int `yaml:"metric_event_pop_batch_size"`
// Metric event pop operation delay
MetricEventPopDelay string `yaml:"metric_event_pop_delay"`
// Duration of check that is considered critical and must be logged
CriticalTimeOfCheck string `yaml:"critical_time_of_check"`
}

func handleParallelChecks(parallelChecks *int) bool {
Expand Down Expand Up @@ -119,6 +121,7 @@ func (config *config) getSettings(logger moira.Logger) *checker.Config {
LogTriggersToLevel: logTriggersToLevel,
MetricEventPopBatchSize: int64(config.Checker.MetricEventPopBatchSize),
MetricEventPopDelay: to.Duration(config.Checker.MetricEventPopDelay),
CriticalTimeOfCheck: to.Duration(config.Checker.CriticalTimeOfCheck),
}
}

Expand All @@ -138,6 +141,7 @@ func getDefault() config {
NoDataCheckInterval: "60s",
LazyTriggersCheckInterval: "10m",
StopCheckingInterval: "30s",
CriticalTimeOfCheck: "1h",
},
Telemetry: cmd.TelemetryConfig{
Listen: ":8092",
Expand Down

0 comments on commit 1dd7c8b

Please sign in to comment.