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.

chore: handle error before using task (#6055)

Srikanth Chekurib49ed913c754
diff --git a/pkg/query-service/rules/manager.go b/pkg/query-service/rules/manager.go
index 09eb7ad367..75b2b5fade 100644
--- a/pkg/query-service/rules/manager.go
+++ b/pkg/query-service/rules/manager.go
@@ -476,15 +476,15 @@ func (m *Manager) addTask(rule *PostableRule, taskName string) error {
UseLogsNewSchema: m.opts.UseLogsNewSchema,
})
- for _, r := range newTask.Rules() {
- m.rules[r.ID()] = r
- }
-
if err != nil {
zap.L().Error("creating rule task failed", zap.String("name", taskName), zap.Error(err))
return errors.New("error loading rules, previous rule set restored")
}
+ for _, r := range newTask.Rules() {
+ m.rules[r.ID()] = r
+ }
+
// If there is an another task with the same identifier, raise an error
_, ok := m.tasks[taskName]
if ok {