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.
TypeScript apmapplication-monitoringdistributed-tracinggogood-first-issuejaegerloglogsmetricsmonitoringnextjsobservabilityopen-sourceopentelemetryprometheusreactreactjsself-hostedtracingtypescript
chore: do not allow deleting more than one panel on update request (#3703)
Srikanth Chekuri2c96512a8ae8
diff --git a/pkg/query-service/app/dashboards/model.go b/pkg/query-service/app/dashboards/model.goindex 2403775cb8..e97facff62 100644--- a/pkg/query-service/app/dashboards/model.go+++ b/pkg/query-service/app/dashboards/model.go@@ -147,8 +147,9 @@ func CreateDashboard(data map[string]interface{}, fm interfaces.FeatureLookup) (return nil, &model.ApiError{Typ: model.ErrorExec, Err: err}}- if countTraceAndLogsPanel(data) > 0 {- fErr := checkFeatureUsage(fm, countTraceAndLogsPanel(data))+ newCount, _ := countTraceAndLogsPanel(data)+ if newCount > 0 {+ fErr := checkFeatureUsage(fm, newCount)if fErr != nil {return nil, fErr}@@ -168,7 +169,7 @@ func CreateDashboard(data map[string]interface{}, fm interfaces.FeatureLookup) (}dash.Id = int(lastInsertId)- traceAndLogsPanelUsage := countTraceAndLogsPanel(data)+ traceAndLogsPanelUsage, _ := countTraceAndLogsPanel(data)if traceAndLogsPanelUsage > 0 {updateFeatureUsage(fm, traceAndLogsPanelUsage)}@@ -213,7 +214,7 @@ func DeleteDashboard(uuid string, fm interfaces.FeatureLookup) *model.ApiError {return &model.ApiError{Typ: model.ErrorNotFound, Err: fmt.Errorf("no dashboard found with uuid: %s", uuid)}}- traceAndLogsPanelUsage := countTraceAndLogsPanel(dashboard.Data)+ traceAndLogsPanelUsage, _ := countTraceAndLogsPanel(dashboard.Data)if traceAndLogsPanelUsage > 0 {updateFeatureUsage(fm, -traceAndLogsPanelUsage)}@@ -248,8 +249,8 @@ func UpdateDashboard(uuid string, data map[string]interface{}, fm interfaces.Fea}// check if the count of trace and logs QB panel has changed, if yes, then check feature flag count- existingCount := countTraceAndLogsPanel(dashboard.Data)- newCount := countTraceAndLogsPanel(data)+ existingCount, existingTotal := countTraceAndLogsPanel(dashboard.Data)+ newCount, newTotal := countTraceAndLogsPanel(data)if newCount > existingCount {err := checkFeatureUsage(fm, newCount-existingCount)if err != nil {@@ -257,6 +258,12 @@ func UpdateDashboard(uuid string, data map[string]interface{}, fm interfaces.Fea}}+ if existingTotal > newTotal && existingTotal-newTotal > 1 {+ // if the total count of panels has reduced by more than 1,+ // return error+ return nil, model.BadRequest(fmt.Errorf("deleting more than one panel is not supported"))+ }+dashboard.UpdatedAt = time.Now()dashboard.Data = data@@ -588,8 +595,9 @@ func TransformGrafanaJSONToSignoz(grafanaJSON model.GrafanaJSON) model.Dashboardreturn toReturn}-func countTraceAndLogsPanel(data map[string]interface{}) int64 {+func countTraceAndLogsPanel(data map[string]interface{}) (int64, int64) {count := int64(0)+ totalPanels := int64(0)if data != nil && data["widgets"] != nil {widgets, ok := data["widgets"].(interface{})if ok {@@ -598,6 +606,7 @@ func countTraceAndLogsPanel(data map[string]interface{}) int64 {for _, widget := range data {sData, ok := widget.(map[string]interface{})if ok && sData["query"] != nil {+ totalPanels++query, ok := sData["query"].(interface{}).(map[string]interface{})if ok && query["queryType"] == "builder" && query["builder"] != nil {builderData, ok := query["builder"].(interface{}).(map[string]interface{})@@ -620,5 +629,5 @@ func countTraceAndLogsPanel(data map[string]interface{}) int64 {}}}- return count+ return count, totalPanels}