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
fix: add validations for aggregates on logs/traces datasource (#2709)
Vishal Sharmad67f709b8a72
diff --git a/pkg/query-service/app/traces/v3/query_builder_test.go b/pkg/query-service/app/traces/v3/query_builder_test.goindex 4fd404e624..9cda548b9e 100644--- a/pkg/query-service/app/traces/v3/query_builder_test.go+++ b/pkg/query-service/app/traces/v3/query_builder_test.go@@ -374,6 +374,21 @@ var testBuildTracesQueryData = []struct {" from signoz_traces.distributed_signoz_index_v2 where (timestamp >= '1680066360726210000' AND timestamp <= '1680066458000000000')" +" group by ts order by ts",},+ {+ Name: "Test aggregate rate without aggregate attribute",+ Start: 1680066360726210000,+ End: 1680066458000000000,+ Step: 60,+ BuilderQuery: &v3.BuilderQuery{+ QueryName: "A",+ AggregateOperator: v3.AggregateOperatorRate,+ Expression: "A",+ },+ TableName: "signoz_traces.distributed_signoz_index_v2",+ ExpectedQuery: "SELECT toStartOfInterval(timestamp, INTERVAL 60 SECOND) AS ts, count()/60 as value from" ++ " signoz_traces.distributed_signoz_index_v2 where (timestamp >= '1680066360726210000' AND timestamp <=" ++ " '1680066458000000000') group by ts order by ts",+ },{Name: "Test aggregate count on fixed column of float64 type with filter",Start: 1680066360726210000,diff --git a/pkg/query-service/model/v3/v3.go b/pkg/query-service/model/v3/v3.goindex 4065fb0668..166f4c57af 100644--- a/pkg/query-service/model/v3/v3.go+++ b/pkg/query-service/model/v3/v3.go@@ -104,10 +104,26 @@ func (a AggregateOperator) Validate() error {func (a AggregateOperator) RequireAttribute(dataSource DataSource) bool {switch dataSource {case DataSourceMetrics:+ switch a {+ case AggregateOperatorNoOp:+ return false+ default:+ return true+ }+ case DataSourceLogs:+ switch a {+ case AggregateOperatorNoOp,+ AggregateOperatorCount,+ AggregateOperatorRate:+ return false+ default:+ return true+ }+ case DataSourceTraces:switch a {case AggregateOperatorNoOp,AggregateOperatorCount,- AggregateOperatorCountDistinct:+ AggregateOperatorRate:return falsedefault:return true