fix: aggregate of avg and percentile (#1045)

This commit is contained in:
Vishal Sharma 2022-05-03 23:02:49 +05:30 committed by GitHub
parent 831381a1ff
commit 81cc120539
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 11 deletions

View File

@ -2069,19 +2069,19 @@ func (r *ClickHouseReader) GetFilteredSpansAggregates(ctx context.Context, query
if queryParams.Dimension == "duration" {
switch queryParams.AggregationOption {
case "p50":
aggregation_query = " quantile(0.50)(durationNano) as value "
aggregation_query = " quantile(0.50)(durationNano) as float64Value "
case "p95":
aggregation_query = " quantile(0.95)(durationNano) as value "
aggregation_query = " quantile(0.95)(durationNano) as float64Value "
case "p90":
aggregation_query = " quantile(0.90)(durationNano) as value "
aggregation_query = " quantile(0.90)(durationNano) as float64Value "
case "p99":
aggregation_query = " quantile(0.99)(durationNano) as value "
aggregation_query = " quantile(0.99)(durationNano) as float64Value "
case "max":
aggregation_query = " max(durationNano) as value "
case "min":
aggregation_query = " min(durationNano) as value "
case "avg":
aggregation_query = " avg(durationNano) as value "
aggregation_query = " avg(durationNano) as float64Value "
case "sum":
aggregation_query = " sum(durationNano) as value "
default:
@ -2222,7 +2222,9 @@ func (r *ClickHouseReader) GetFilteredSpansAggregates(ctx context.Context, query
}
for i := range SpanAggregatesDBResponseItems {
if SpanAggregatesDBResponseItems[i].Value == 0 {
SpanAggregatesDBResponseItems[i].Value = uint64(SpanAggregatesDBResponseItems[i].Float64Value)
}
SpanAggregatesDBResponseItems[i].Timestamp = int64(SpanAggregatesDBResponseItems[i].Time.UnixNano())
SpanAggregatesDBResponseItems[i].FloatValue = float32(SpanAggregatesDBResponseItems[i].Value)
if queryParams.AggregationOption == "rate_per_sec" {

View File

@ -233,11 +233,12 @@ type SpanAggregatesResponseItem struct {
GroupBy map[string]float32 `json:"groupBy,omitempty"`
}
type SpanAggregatesDBResponseItem struct {
Timestamp int64 `ch:"timestamp" `
Time time.Time `ch:"time"`
Value uint64 `ch:"value"`
FloatValue float32 `ch:"floatValue"`
GroupBy string `ch:"groupBy"`
Timestamp int64 `ch:"timestamp" `
Time time.Time `ch:"time"`
Value uint64 `ch:"value"`
FloatValue float32 `ch:"floatValue"`
Float64Value float64 `ch:"float64Value"`
GroupBy string `ch:"groupBy"`
}
type SetTTLResponseItem struct {