Skip to content

SigNoz is an open-source, OpenTelemetry-native observability platform for your team and their AI agents. Get logs, metrics, and traces in one tool with features like APM, distributed tracing, log management, infra monitoring, etc. Combined with SigNoz MCP and a native AI teammate (in SigNoz Cloud) it helps you build more resilient apps.

fix: do not crash service on panic during rule eval (#7514)

Srikanth Chekurib40ca4baf375
diff --git a/pkg/query-service/rules/prom_rule_task.go b/pkg/query-service/rules/prom_rule_task.go
index 8c7aafb289..1c895475dc 100644
--- a/pkg/query-service/rules/prom_rule_task.go
+++ b/pkg/query-service/rules/prom_rule_task.go
@@ -315,6 +315,13 @@ func (g *PromRuleTask) CopyState(fromTask Task) error {
// Eval runs a single evaluation cycle in which all rules are evaluated sequentially.
func (g *PromRuleTask) Eval(ctx context.Context, ts time.Time) {
+
+ defer func() {
+ if r := recover(); r != nil {
+ zap.L().Error("panic during promql rule evaluation", zap.Any("panic", r))
+ }
+ }()
+
zap.L().Info("promql rule task", zap.String("name", g.name), zap.Time("eval started at", ts))
maintenance, err := g.ruleDB.GetAllPlannedMaintenance(ctx)
diff --git a/pkg/query-service/rules/rule_task.go b/pkg/query-service/rules/rule_task.go
index aa8ad60b77..bb53f1e33b 100644
--- a/pkg/query-service/rules/rule_task.go
+++ b/pkg/query-service/rules/rule_task.go
@@ -297,6 +297,12 @@ func (g *RuleTask) CopyState(fromTask Task) error {
// Eval runs a single evaluation cycle in which all rules are evaluated sequentially.
func (g *RuleTask) Eval(ctx context.Context, ts time.Time) {
+ defer func() {
+ if r := recover(); r != nil {
+ zap.L().Error("panic during threshold rule evaluation", zap.Any("panic", r))
+ }
+ }()
+
zap.L().Debug("rule task eval started", zap.String("name", g.name), zap.Time("start time", ts))
maintenance, err := g.ruleDB.GetAllPlannedMaintenance(ctx)