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: don't run functions if the series is empty (#10725)

Nityananda Gohain23a4960e74ec
diff --git a/pkg/types/querybuildertypes/querybuildertypesv5/functions.go b/pkg/types/querybuildertypes/querybuildertypesv5/functions.go
index 9af396aec4..d7874a2dbc 100644
--- a/pkg/types/querybuildertypes/querybuildertypesv5/functions.go
+++ b/pkg/types/querybuildertypes/querybuildertypesv5/functions.go
@@ -102,6 +102,10 @@ func (fn FunctionName) Validate() error {
// ApplyFunction applies the given function to the result data
func ApplyFunction(fn Function, result *TimeSeries) *TimeSeries {
+ if len(result.Values) == 0 {
+ return result
+ }
+
// Extract the function name and arguments
name := fn.Name
args := fn.Args
diff --git a/pkg/types/querybuildertypes/querybuildertypesv5/functions_test.go b/pkg/types/querybuildertypes/querybuildertypesv5/functions_test.go
index dbd5fc8b6b..4fc61695ef 100644
--- a/pkg/types/querybuildertypes/querybuildertypesv5/functions_test.go
+++ b/pkg/types/querybuildertypes/querybuildertypesv5/functions_test.go
@@ -599,6 +599,14 @@ func TestApplyFunction(t *testing.T) {
values []float64
want []float64
}{
+ {
+ name: "test with empty series",
+ function: Function{
+ Name: FunctionNameRunningDiff,
+ },
+ values: []float64{},
+ want: []float64{},
+ },
{
name: "cutOffMin function",
function: Function{