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: remove metrics pre-aggregation flag (#9935)
Karan Balanib744e228c7b6
diff --git a/pkg/query-service/app/metrics/v4/helpers/sub_query.go b/pkg/query-service/app/metrics/v4/helpers/sub_query.goindex 534315799d..2782638429 100644--- a/pkg/query-service/app/metrics/v4/helpers/sub_query.go+++ b/pkg/query-service/app/metrics/v4/helpers/sub_query.go@@ -64,15 +64,9 @@ func whichTSTableToUse(start, end int64, mq *v3.BuilderQuery) (int64, int64, strstart = start - (start % (time.Hour.Milliseconds() * 24))tableName = constants.SIGNOZ_TIMESERIES_v4_1DAY_LOCAL_TABLENAME} else {- if constants.UseMetricsPreAggregation() {- // adjust the start time to nearest 1 week- start = start - (start % (time.Hour.Milliseconds() * 24 * 7))- tableName = constants.SIGNOZ_TIMESERIES_v4_1WEEK_LOCAL_TABLENAME- } else {- // continue to use the 1 day table- start = start - (start % (time.Hour.Milliseconds() * 24))- tableName = constants.SIGNOZ_TIMESERIES_v4_1DAY_LOCAL_TABLENAME- }+ // adjust the start time to nearest 1 week+ start = start - (start % (time.Hour.Milliseconds() * 24 * 7))+ tableName = constants.SIGNOZ_TIMESERIES_v4_1WEEK_LOCAL_TABLENAME}return start, end, tableName@@ -99,11 +93,6 @@ func WhichSamplesTableToUse(start, end int64, mq *v3.BuilderQuery) string {return constants.SIGNOZ_EXP_HISTOGRAM_TABLENAME}- // continue to use the old table if pre-aggregation is disabled- if !constants.UseMetricsPreAggregation() {- return constants.SIGNOZ_SAMPLES_V4_TABLENAME- }-// if the time aggregation is count_distinct, we need to use the distributed_samples_v4 table// because the aggregated tables don't support count_distinctif mq.TimeAggregation == v3.TimeAggregationCountDistinct {diff --git a/pkg/query-service/app/metrics/v4/query_builder_pre_agg_test.go b/pkg/query-service/app/metrics/v4/query_builder_pre_agg_test.goindex d1c314dfc0..607ded09af 100644--- a/pkg/query-service/app/metrics/v4/query_builder_pre_agg_test.go+++ b/pkg/query-service/app/metrics/v4/query_builder_pre_agg_test.go@@ -9,7 +9,6 @@ import ()func TestPrepareMetricQueryCumulativeRatePreAgg(t *testing.T) {- t.Setenv("USE_METRICS_PRE_AGGREGATION", "true")testCases := []struct {name stringbuilderQuery *v3.BuilderQuery@@ -98,7 +97,6 @@ func TestPrepareMetricQueryCumulativeRatePreAgg(t *testing.T) {}func TestPrepareMetricQueryDeltaRatePreAgg(t *testing.T) {- t.Setenv("USE_METRICS_PRE_AGGREGATION", "true")testCases := []struct {name stringbuilderQuery *v3.BuilderQuery@@ -165,7 +163,6 @@ func TestPrepareMetricQueryDeltaRatePreAgg(t *testing.T) {}func TestPrepreMetricQueryCumulativeQuantilePreAgg(t *testing.T) {- t.Setenv("USE_METRICS_PRE_AGGREGATION", "true")testCases := []struct {name stringbuilderQuery *v3.BuilderQuery@@ -250,7 +247,6 @@ func TestPrepreMetricQueryCumulativeQuantilePreAgg(t *testing.T) {}func TestPrepreMetricQueryDeltaQuantilePreAgg(t *testing.T) {- t.Setenv("USE_METRICS_PRE_AGGREGATION", "true")testCases := []struct {name stringbuilderQuery *v3.BuilderQuery@@ -335,7 +331,6 @@ func TestPrepreMetricQueryDeltaQuantilePreAgg(t *testing.T) {}func TestPrepareMetricQueryGaugePreAgg(t *testing.T) {- t.Setenv("USE_METRICS_PRE_AGGREGATION", "true")testCases := []struct {name stringbuilderQuery *v3.BuilderQuerydiff --git a/pkg/query-service/app/metrics/v4/query_builder_test.go b/pkg/query-service/app/metrics/v4/query_builder_test.goindex 6af48a102c..85b3b03dc5 100644--- a/pkg/query-service/app/metrics/v4/query_builder_test.go+++ b/pkg/query-service/app/metrics/v4/query_builder_test.go@@ -202,7 +202,6 @@ func TestPrepareTimeseriesFilterQuery(t *testing.T) {}func TestPrepareMetricQueryCumulativeRate(t *testing.T) {- t.Setenv("USE_METRICS_PRE_AGGREGATION", "false")testCases := []struct {name stringbuilderQuery *v3.BuilderQuery@@ -291,7 +290,6 @@ func TestPrepareMetricQueryCumulativeRate(t *testing.T) {}func TestPrepareMetricQueryDeltaRate(t *testing.T) {- t.Setenv("USE_METRICS_PRE_AGGREGATION", "false")testCases := []struct {name stringbuilderQuery *v3.BuilderQuery@@ -358,7 +356,6 @@ func TestPrepareMetricQueryDeltaRate(t *testing.T) {}func TestPrepreMetricQueryCumulativeQuantile(t *testing.T) {- t.Setenv("USE_METRICS_PRE_AGGREGATION", "false")testCases := []struct {name stringbuilderQuery *v3.BuilderQuery@@ -443,7 +440,6 @@ func TestPrepreMetricQueryCumulativeQuantile(t *testing.T) {}func TestPrepreMetricQueryDeltaQuantile(t *testing.T) {- t.Setenv("USE_METRICS_PRE_AGGREGATION", "false")testCases := []struct {name stringbuilderQuery *v3.BuilderQuery@@ -528,7 +524,6 @@ func TestPrepreMetricQueryDeltaQuantile(t *testing.T) {}func TestPrepareMetricQueryGauge(t *testing.T) {- t.Setenv("USE_METRICS_PRE_AGGREGATION", "false")testCases := []struct {name stringbuilderQuery *v3.BuilderQuery@@ -695,7 +690,6 @@ func TestPrepareMetricQueryGauge(t *testing.T) {}func TestPrepareMetricQueryValueTypePanelWithGroupBY(t *testing.T) {- t.Setenv("USE_METRICS_PRE_AGGREGATION", "false")testCases := []struct {name stringbuilderQuery *v3.BuilderQuerydiff --git a/pkg/query-service/app/parser.go b/pkg/query-service/app/parser.goindex 4480cc9897..89fa14a35d 100644--- a/pkg/query-service/app/parser.go+++ b/pkg/query-service/app/parser.go@@ -819,7 +819,7 @@ func ParseQueryRangeParams(r *http.Request) (*v3.QueryRangeParamsV3, *model.ApiEquery.StepInterval = minStep}- if query.DataSource == v3.DataSourceMetrics && baseconstants.UseMetricsPreAggregation() {+ if query.DataSource == v3.DataSourceMetrics {// if the time range is greater than 1 day, and less than 1 week set the step interval to be multiple of 5 minutes// if the time range is greater than 1 week, set the step interval to be multiple of 30 minsstart, end := queryRangeParams.Start, queryRangeParams.Enddiff --git a/pkg/query-service/constants/constants.go b/pkg/query-service/constants/constants.goindex d8d7b2d5cd..5884fec16c 100644--- a/pkg/query-service/constants/constants.go+++ b/pkg/query-service/constants/constants.go@@ -40,11 +40,6 @@ const NormalizedMetricsMapQueryThreads = 10var NormalizedMetricsMapRegex = regexp.MustCompile(`[^a-zA-Z0-9]`)var NormalizedMetricsMapQuantileRegex = regexp.MustCompile(`(?i)([._-]?quantile.*)$`)-// TODO(srikanthccv): remove after backfilling is done-func UseMetricsPreAggregation() bool {- return GetOrDefaultEnv("USE_METRICS_PRE_AGGREGATION", "true") == "true"-}-var KafkaSpanEval = GetOrDefaultEnv("KAFKA_SPAN_EVAL", "false")func GetEvalDelay() time.Duration {diff --git a/pkg/query-service/rules/threshold_rule.go b/pkg/query-service/rules/threshold_rule.goindex 50d8f02661..2d81f98328 100644--- a/pkg/query-service/rules/threshold_rule.go+++ b/pkg/query-service/rules/threshold_rule.go@@ -166,7 +166,7 @@ func (r *ThresholdRule) prepareQueryRange(ctx context.Context, ts time.Time) (*vq.SetShiftByFromFunc()- if q.DataSource == v3.DataSourceMetrics && constants.UseMetricsPreAggregation() {+ if q.DataSource == v3.DataSourceMetrics {// if the time range is greater than 1 day, and less than 1 week set the step interval to be multiple of 5 minutes// if the time range is greater than 1 week, set the step interval to be multiple of 30 minsif end-start >= 24*time.Hour.Milliseconds() && end-start < 7*24*time.Hour.Milliseconds() {diff --git a/pkg/query-service/utils/filter_conditions.go b/pkg/query-service/utils/filter_conditions.goindex 14aa909841..d1a27fcfa5 100644--- a/pkg/query-service/utils/filter_conditions.go+++ b/pkg/query-service/utils/filter_conditions.go@@ -126,17 +126,10 @@ func WhichTSTableToUse(start, end int64) (int64, int64, string, string) {tableName = constants.SIGNOZ_TIMESERIES_v4_1DAY_TABLENAMElocalTableName = constants.SIGNOZ_TIMESERIES_v4_1DAY_LOCAL_TABLENAME} else {- if constants.UseMetricsPreAggregation() {- // adjust the start time to nearest 1 week- start = start - (start % (time.Hour.Milliseconds() * 24 * 7))- tableName = constants.SIGNOZ_TIMESERIES_v4_1WEEK_TABLENAME- localTableName = constants.SIGNOZ_TIMESERIES_v4_1WEEK_LOCAL_TABLENAME- } else {- // continue to use the 1 day table- start = start - (start % (time.Hour.Milliseconds() * 24))- tableName = constants.SIGNOZ_TIMESERIES_v4_1DAY_TABLENAME- localTableName = constants.SIGNOZ_TIMESERIES_v4_1DAY_LOCAL_TABLENAME- }+ // adjust the start time to nearest 1 week+ start = start - (start % (time.Hour.Milliseconds() * 24 * 7))+ tableName = constants.SIGNOZ_TIMESERIES_v4_1WEEK_TABLENAME+ localTableName = constants.SIGNOZ_TIMESERIES_v4_1WEEK_LOCAL_TABLENAME}return start, end, tableName, localTableName