Skip to content

Commit

Permalink
fix: removed caching for all other panel type for expression except t…
Browse files Browse the repository at this point in the history
…ime series (#6720)

Co-authored-by: Aniket <aniket@Anikets-MacBook-Pro-2.local>
Co-authored-by: Srikanth Chekuri <srikanth.chekuri92@gmail.com>
  • Loading branch information
3 people authored Dec 28, 2024
1 parent f11161d commit 93e9d15
Show file tree
Hide file tree
Showing 2 changed files with 84 additions and 0 deletions.
3 changes: 3 additions & 0 deletions pkg/query-service/app/queryBuilder/query_builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -441,6 +441,9 @@ func (c *cacheKeyGenerator) GenerateKeys(params *v3.QueryRangeParamsV3) map[stri
// Build keys for each expression
for _, query := range params.CompositeQuery.BuilderQueries {
if query.Expression != query.QueryName {
if params.Version != "v4" && params.CompositeQuery.PanelType != v3.PanelTypeGraph {
continue
}
expression, _ := govaluate.NewEvaluableExpressionWithFunctions(query.Expression, EvalFuncs)

if !isMetricExpression(expression, params) && !isLogExpression(expression, params) {
Expand Down
81 changes: 81 additions & 0 deletions pkg/query-service/app/queryBuilder/query_builder_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1206,6 +1206,87 @@ func TestGenerateCacheKeysMetricsBuilder(t *testing.T) {
"A": "source=metrics&step=60&aggregate=sum_rate&timeAggregation=&spaceAggregation=&aggregateAttribute=signoz_latency_bucket---false&filter-0=key:service_name---false,op:=,value:A&groupBy-0=service_name---false&groupBy-1=le---false&having-0=column:value,op:>,value:100",
},
},
{
name: "version=v3;panelType=value;dataSource=metrics;queryType=builder with expression", //not caching panel type value for v3
query: &v3.QueryRangeParamsV3{
Version: "v3",
CompositeQuery: &v3.CompositeQuery{
QueryType: v3.QueryTypeBuilder,
PanelType: v3.PanelTypeValue,
FillGaps: false,
BuilderQueries: map[string]*v3.BuilderQuery{
"A": {
QueryName: "A",
DataSource: v3.DataSourceMetrics,
AggregateOperator: v3.AggregateOperatorNoOp,
AggregateAttribute: v3.AttributeKey{
Key: "system_memory_usage",
DataType: v3.AttributeKeyDataTypeFloat64,
Type: v3.AttributeKeyType("Gauge"),
IsColumn: true,
},
TimeAggregation: v3.TimeAggregationUnspecified,
SpaceAggregation: v3.SpaceAggregationSum,
Filters: &v3.FilterSet{
Operator: "AND",
Items: []v3.FilterItem{
{
Key: v3.AttributeKey{
Key: "state",
DataType: v3.AttributeKeyDataTypeString,
Type: v3.AttributeKeyTypeTag,
IsColumn: false,
},
Operator: v3.FilterOperatorEqual,
Value: "cached",
},
},
},
Expression: "A",
Disabled: true,
StepInterval: 60,
},
"B": {
QueryName: "B",
DataSource: v3.DataSourceMetrics,
AggregateOperator: v3.AggregateOperatorNoOp,
AggregateAttribute: v3.AttributeKey{
Key: "system_memory_usage",
DataType: v3.AttributeKeyDataTypeFloat64,
Type: v3.AttributeKeyType("Gauge"),
IsColumn: true,
},
TimeAggregation: v3.TimeAggregationUnspecified,
SpaceAggregation: v3.SpaceAggregationSum,
Filters: &v3.FilterSet{
Operator: "AND",
Items: []v3.FilterItem{
{
Key: v3.AttributeKey{
Key: "state",
DataType: v3.AttributeKeyDataTypeString,
Type: v3.AttributeKeyTypeTag,
IsColumn: false,
},
Operator: v3.FilterOperatorEqual,
Value: "cached",
},
},
},
Expression: "B",
Disabled: true,
StepInterval: 60,
},
"F1": {
QueryName: "F1",
Expression: "A+B",
Disabled: false,
},
},
},
},
expectedCacheKeys: map[string]string{},
},
{
name: "version=v4;panelType=table;dataSource=metrics;queryType=builder",
query: &v3.QueryRangeParamsV3{
Expand Down

0 comments on commit 93e9d15

Please sign in to comment.