Skip to content

Commit

Permalink
chore: conditionally fetch temporality when --prefer-delta is set
Browse files Browse the repository at this point in the history
  • Loading branch information
srikanthccv committed Jul 13, 2023
1 parent b195051 commit 0c20208
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions pkg/query-service/app/http_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -458,16 +458,26 @@ func (aH *APIHandler) metricAutocompleteTagValue(w http.ResponseWriter, r *http.
func (aH *APIHandler) addTemporality(ctx context.Context, qp *v3.QueryRangeParamsV3) error {

metricNames := make([]string, 0)
metricNameToTemporality := make(map[string]map[v3.Temporality]bool)
if qp.CompositeQuery != nil && len(qp.CompositeQuery.BuilderQueries) > 0 {
for _, query := range qp.CompositeQuery.BuilderQueries {
if query.DataSource == v3.DataSourceMetrics {
metricNames = append(metricNames, query.AggregateAttribute.Key)
if _, ok := metricNameToTemporality[query.AggregateAttribute.Key]; !ok {
metricNameToTemporality[query.AggregateAttribute.Key] = make(map[v3.Temporality]bool)
}
}
}
}
metricNameToTemporality, err := aH.reader.FetchTemporality(ctx, metricNames)
if err != nil {
return err

var err error

if aH.preferDelta {
zap.S().Debug("fetching metric temporality")
metricNameToTemporality, err = aH.reader.FetchTemporality(ctx, metricNames)
if err != nil {
return err
}
}

if qp.CompositeQuery != nil && len(qp.CompositeQuery.BuilderQueries) > 0 {
Expand Down

0 comments on commit 0c20208

Please sign in to comment.