Sfoglia il codice sorgente

Memory Optimizations (#3892)

Signed-off-by: Nik Willwerth <nwillwerth@kubecost.com>
nik-kc 1 giorno fa
parent
commit
eebce4c00e
2 ha cambiato i file con 7 aggiunte e 0 eliminazioni
  1. 1 0
      pkg/cloudcost/querier.go
  2. 6 0
      pkg/cloudcost/queryservice_helper.go

+ 1 - 0
pkg/cloudcost/querier.go

@@ -43,6 +43,7 @@ type ViewQueryRequest struct {
 	Limit            int
 	SortDirection    SortDirection
 	SortColumn       SortField
+	SkipCount        bool
 }
 
 // SortDirection a string type that acts as an enumeration of possible request options

+ 6 - 0
pkg/cloudcost/queryservice_helper.go

@@ -96,6 +96,11 @@ func ParseCloudCostViewRequest(qp httputil.QueryParams) (*ViewQueryRequest, erro
 		return nil, fmt.Errorf("error parsing 'sortBy': %w", err)
 	}
 
+	// includeCount controls whether the (potentially very expensive) NumResults
+	// count is computed alongside the combined cost. Defaults to true; callers
+	// pass includeCount=false to skip it.
+	includeCount := qp.GetBool("includeCount", true)
+
 	return &ViewQueryRequest{
 		QueryRequest:     *qr,
 		CostMetricName:   costMetricName,
@@ -104,6 +109,7 @@ func ParseCloudCostViewRequest(qp httputil.QueryParams) (*ViewQueryRequest, erro
 		Offset:           offset,
 		SortDirection:    order,
 		SortColumn:       sortColumn,
+		SkipCount:        !includeCount,
 	}, nil
 }