mirror of
https://github.com/rcourtman/Pulse.git
synced 2026-07-09 16:00:59 +00:00
Delete the residual internal/alerts/alerts.go catch-all and move its remaining ownership groups into config_facade, model, constants, metric_hooks, manager, default_config, lifecycle, and escalation files. Keep compatibility aliases in the alerts package, preserve the type-alias identity test, add a default-config pointer isolation regression test, and record the new ownership split in the alerts subsystem contract. Proof: git diff --check -- docs/release-control/v6/internal/subsystems/alerts.md internal/alerts Proof: go test ./internal/alerts/... -run 'TestDefaultAlertConfigUsesIndependentBackupAlertOrphanedPointer|TestTypeAliasIdentity|TestSetMetricHooks|TestSetLicenseCheckerStoresChecker|TestHistoryManager_Stop|TestEscalationDisabledWhenAlertsDisabled|TestEscalationDisabledWhenActivationPending|TestEscalationDisabledWhenActivationSnoozed|TestEscalationSkipsWhenScheduleDisabled|TestEscalationSkipsAcknowledgedAlerts|TestEscalationAdvancesLevels|TestEscalationDoesNotRepeatSameLevel|TestEscalationUsesCallback' -count=1 Proof: go test ./internal/alerts/... -count=1 Proof: go test ./internal/api -run Alert -count=1
21 lines
792 B
Go
21 lines
792 B
Go
package alerts
|
|
|
|
// Metric hooks for integrating with Prometheus
|
|
var (
|
|
recordAlertFired func(*Alert)
|
|
recordAlertResolved func(*Alert)
|
|
recordAlertSuppressed func(string)
|
|
recordAlertAcknowledged func()
|
|
)
|
|
|
|
// SetMetricHooks registers callbacks for recording alert metrics.
|
|
// - fired: called when an alert is dispatched (in dispatchAlert)
|
|
// - resolved: called when an alert is cleared (in clearAlertNoLock)
|
|
// - suppressed: called when an alert is suppressed due to flapping
|
|
// - acknowledged: called when an alert is acknowledged
|
|
func SetMetricHooks(fired func(*Alert), resolved func(*Alert), suppressed func(string), acknowledged func()) {
|
|
recordAlertFired = fired
|
|
recordAlertResolved = resolved
|
|
recordAlertSuppressed = suppressed
|
|
recordAlertAcknowledged = acknowledged
|
|
}
|