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: always add reserved vars (#7689)
Srikanth Chekuria9c09f33cbe5
diff --git a/go.mod b/go.modindex f5b29cb91d..b4e0b95fe1 100644--- a/go.mod+++ b/go.mod@@ -6,7 +6,7 @@ toolchain go1.22.11require (dario.cat/mergo v1.0.1- github.com/AfterShip/clickhouse-sql-parser v0.4.4+ github.com/AfterShip/clickhouse-sql-parser v0.4.7github.com/ClickHouse/clickhouse-go/v2 v2.30.0github.com/DATA-DOG/go-sqlmock v1.5.2github.com/SigNoz/govaluate v0.0.0-20240203125216-988004ccc7fddiff --git a/go.sum b/go.sumindex 551fdbceba..a1905d8f24 100644--- a/go.sum+++ b/go.sum@@ -64,8 +64,8 @@ dario.cat/mergo v1.0.1/go.mod h1:uNxQE+84aUszobStD9th8a29P2fMDhsBdgRYvZOxGmk=dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU=filippo.io/edwards25519 v1.1.0 h1:FNf4tywRC1HmFuKW5xopWpigGjJKiJSV0Cqo0cJWDaA=filippo.io/edwards25519 v1.1.0/go.mod h1:BxyFTGdWcka3PhytdK4V28tE5sGfRvvvRV7EaN4VDT4=-github.com/AfterShip/clickhouse-sql-parser v0.4.4 h1:iLRwjzz1mWmUEf5UNrSYOceQ+PX9SdBJ8Xw0DNrL114=-github.com/AfterShip/clickhouse-sql-parser v0.4.4/go.mod h1:W0Z82wJWkJxz2RVun/RMwxue3g7ut47Xxl+SFqdJGus=+github.com/AfterShip/clickhouse-sql-parser v0.4.7 h1:zbdC0UooWLwBvOi5CeyCA42AWm6lMYuBVy6XnMzmF+c=+github.com/AfterShip/clickhouse-sql-parser v0.4.7/go.mod h1:W0Z82wJWkJxz2RVun/RMwxue3g7ut47Xxl+SFqdJGus=github.com/Azure/azure-sdk-for-go v68.0.0+incompatible h1:fcYLmCpyNYRnvJbPerq7U0hS+6+I79yEDJBqVNcqUzU=github.com/Azure/azure-sdk-for-go/sdk/azcore v1.16.0 h1:JZg6HRh6W6U4OLl6lk7BZ7BLisIzM9dG1R50zUk9C/M=github.com/Azure/azure-sdk-for-go/sdk/azcore v1.16.0/go.mod h1:YL1xnZ6QejvQHWJrX/AvhFl4WW4rqHVoKspWNVwFk0M=@@ -100,8 +100,6 @@ github.com/Microsoft/go-winio v0.6.2/go.mod h1:yd8OoFMLzJbo9gZq8j5qaps8bJ9aShtEAgithub.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU=github.com/SigNoz/govaluate v0.0.0-20240203125216-988004ccc7fd h1:Bk43AsDYe0fhkbj57eGXx8H3ZJ4zhmQXBnrW523ktj8=github.com/SigNoz/govaluate v0.0.0-20240203125216-988004ccc7fd/go.mod h1:nxRcH/OEdM8QxzH37xkGzomr1O0JpYBRS6pwjsWW6Pc=-github.com/SigNoz/signoz-otel-collector v0.111.39-beta.1 h1:ZpSNrOZBOH2iCJIPeER5X0mfxOe64yP3JRX7FzBNfwY=-github.com/SigNoz/signoz-otel-collector v0.111.39-beta.1/go.mod h1:DCu/D+lqhsPNSGS4IMD+4gn7q06TGzOCKazSy+GURVc=github.com/SigNoz/signoz-otel-collector v0.111.39 h1:Dl8QqZNAsj2atxP572OzsszPK0XPpd3LLPNPRAUJ5wo=github.com/SigNoz/signoz-otel-collector v0.111.39/go.mod h1:DCu/D+lqhsPNSGS4IMD+4gn7q06TGzOCKazSy+GURVc=github.com/afex/hystrix-go v0.0.0-20180502004556-fa1af6a1f4f5/go.mod h1:SkGFH1ia65gfNATL8TAiHDNxPzPdmEL5uirI2Uyuz6c=diff --git a/pkg/variables/clickhouse/transform.go b/pkg/variables/clickhouse/transform.goindex 844d81d7bf..40914dab90 100644--- a/pkg/variables/clickhouse/transform.go+++ b/pkg/variables/clickhouse/transform.go@@ -2,9 +2,11 @@ package clickhouseimport ("fmt"+ "slices""strings""github.com/AfterShip/clickhouse-sql-parser/parser"+ "github.com/SigNoz/signoz/pkg/variables")// VariableValue represents a variable's assigned value@@ -23,12 +25,23 @@ type QueryTransformer struct {}// NewQueryTransformer creates a new transformer with the given SQL and variables-func NewQueryTransformer(sql string, variables []VariableValue) *QueryTransformer {+func NewQueryTransformer(sql string, vars []VariableValue) *QueryTransformer {varMap := make(map[string]VariableValue)- for _, v := range variables {+ for _, v := range vars {+ if slices.Contains(variables.ReservedTimeVars, v.Name) {+ continue+ }varMap[v.Name] = v}+ for _, v := range variables.ReservedTimeVars {+ varMap[v] = VariableValue{+ Name: v,+ IsSelectAll: false,+ FieldType: "scalar",+ }+ }+// for each variable, replace the `{{variable_name}}`, [[variable_name]], {{ .variable_name }}, {{.variable_name}}// with $variable_namefor name := range varMap {diff --git a/pkg/variables/reserved_vars.go b/pkg/variables/reserved_vars.gonew file mode 100644index 0000000000..98455ced7d--- /dev/null+++ b/pkg/variables/reserved_vars.go@@ -0,0 +1,14 @@+package variables++var ReservedTimeVars = []string{+ "start_timestamp",+ "end_timestamp",+ "start_timestamp_ms",+ "end_timestamp_ms",+ "SIGNOZ_START_TIME",+ "SIGNOZ_END_TIME",+ "start_timestamp_nano",+ "end_timestamp_nano",+ "start_datetime",+ "end_datetime",+}