diff --git a/pkg/tsdb/tempo/traceql_query.go b/pkg/tsdb/tempo/traceql_query.go index 39476c35fd5..38c07f48767 100644 --- a/pkg/tsdb/tempo/traceql_query.go +++ b/pkg/tsdb/tempo/traceql_query.go @@ -128,7 +128,6 @@ func handleConversionError(ctxLogger log.Logger, span trace.Span, err error) (*b func (s *Service) performMetricsQuery(ctx context.Context, dsInfo *Datasource, model *dataquery.TempoQuery, query backend.DataQuery, span trace.Span) (*http.Response, []byte, error) { ctxLogger := s.logger.FromContext(ctx) request, err := s.createMetricsQuery(ctx, dsInfo, model, query.TimeRange.From.Unix(), query.TimeRange.To.Unix()) - if err != nil { ctxLogger.Error("Failed to create request", "error", err, "function", logEntrypoint()) span.RecordError(err) @@ -202,6 +201,6 @@ func isInstantQuery(metricQueryType *dataquery.MetricsQueryType) bool { } func isMetricsQuery(query string) bool { - match, _ := regexp.MatchString("\\|\\s*(rate|count_over_time|avg_over_time|max_over_time|min_over_time|quantile_over_time|histogram_over_time|compare)\\s*\\(", query) + match, _ := regexp.MatchString("\\|\\s*(rate|count_over_time|avg_over_time|sum_over_time|max_over_time|min_over_time|quantile_over_time|histogram_over_time|compare)\\s*\\(", query) return match } diff --git a/pkg/tsdb/tempo/traceql_query_test.go b/pkg/tsdb/tempo/traceql_query_test.go index e8561c25e02..cffe2c2273f 100644 --- a/pkg/tsdb/tempo/traceql_query_test.go +++ b/pkg/tsdb/tempo/traceql_query_test.go @@ -34,6 +34,7 @@ func TestCreateMetricsQuery_Success(t *testing.T) { assert.Equal(t, "http://tempo:3100/api/metrics/query_range?end=1625184000&exemplars=123&q=%7Battribute%3D%22value%22%7D&start=1625097600&step=14", req.URL.String()) assert.Equal(t, "application/json", req.Header.Get("Accept")) } + func TestCreateMetricsQuery_OnlyQuery(t *testing.T) { logger := backend.NewLoggerWith("logger", "tsdb.tempo.test") service := &Service{ @@ -94,6 +95,11 @@ func TestQueryWithAvgOverTimeFunction_ReturnsTrue(t *testing.T) { assert.True(t, result) } +func TestQueryWithSumOverTimeFunction_ReturnsTrue(t *testing.T) { + result := isMetricsQuery("{} | sum_over_time(foo)") + assert.True(t, result) +} + func TestQueryWithCountOverTimeFunction_ReturnsTrue(t *testing.T) { result := isMetricsQuery("{} | count_over_time(foo)") assert.True(t, result)