From bf4c792cdbdd7191adefa56f635839eb1a097698 Mon Sep 17 00:00:00 2001 From: Srikanth Chekuri Date: Mon, 14 Oct 2024 14:04:49 +0530 Subject: [PATCH] chore: update default feature flag and error response for formula (#6184) --- ee/query-service/app/api/queryrange.go | 13 ++++++++++++- ee/query-service/model/plans.go | 2 +- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/ee/query-service/app/api/queryrange.go b/ee/query-service/app/api/queryrange.go index f5ad490ed5..6047eeeb10 100644 --- a/ee/query-service/app/api/queryrange.go +++ b/ee/query-service/app/api/queryrange.go @@ -53,7 +53,11 @@ func (aH *APIHandler) queryRangeV4(w http.ResponseWriter, r *http.Request) { if anomalyQueryExists { // ensure all queries have metric data source, and there should be only one anomaly query for _, query := range queryRangeParams.CompositeQuery.BuilderQueries { - if query.DataSource != v3.DataSourceMetrics { + // What is query.QueryName == query.Expression doing here? + // In the current implementation, the way to recognize if a query is a formula is by + // checking if the expression is the same as the query name. if the expression is different + // then it is a formula. otherwise, it is simple builder query. + if query.DataSource != v3.DataSourceMetrics && query.QueryName == query.Expression { RespondError(w, &model.ApiError{Typ: model.ErrorBadData, Err: fmt.Errorf("all queries must have metric data source")}, nil) return } @@ -100,6 +104,13 @@ func (aH *APIHandler) queryRangeV4(w http.ResponseWriter, r *http.Request) { anomaly.WithReader[*anomaly.HourlyProvider](aH.opts.DataConnector), anomaly.WithFeatureLookup[*anomaly.HourlyProvider](aH.opts.FeatureFlags), ) + default: + provider = anomaly.NewDailyProvider( + anomaly.WithCache[*anomaly.DailyProvider](aH.opts.Cache), + anomaly.WithKeyGenerator[*anomaly.DailyProvider](queryBuilder.NewKeyGenerator()), + anomaly.WithReader[*anomaly.DailyProvider](aH.opts.DataConnector), + anomaly.WithFeatureLookup[*anomaly.DailyProvider](aH.opts.FeatureFlags), + ) } anomalies, err := provider.GetAnomalies(r.Context(), &anomaly.GetAnomaliesRequest{Params: queryRangeParams}) if err != nil { diff --git a/ee/query-service/model/plans.go b/ee/query-service/model/plans.go index 5b695143b7..e7f02b805e 100644 --- a/ee/query-service/model/plans.go +++ b/ee/query-service/model/plans.go @@ -373,7 +373,7 @@ var EnterprisePlan = basemodel.FeatureSet{ }, basemodel.Feature{ Name: basemodel.AnomalyDetection, - Active: true, + Active: false, Usage: 0, UsageLimit: -1, Route: "",