Skip to content

Commit

Permalink
Fixed PrometheusResponse minTime for histograms in qfe
Browse files Browse the repository at this point in the history
Signed-off-by: Sebastian Rabenhorst <sebastian.rabenhorst@shopify.com>
  • Loading branch information
rabenhorst committed Feb 27, 2023
1 parent 145af66 commit ece82d3
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions internal/cortex/querier/queryrange/query_range.go
Expand Up @@ -154,10 +154,26 @@ func (resp *PrometheusResponse) minTime() int64 {
if len(result) == 0 {
return -1
}
if len(result[0].Samples) == 0 {
if len(result[0].Samples) == 0 && len(result[0].Histograms) == 0 {
return -1
}
return result[0].Samples[0].TimestampMs

if len(result[0].Samples) == 0 {
return result[0].Histograms[0].Timestamp
}

if len(result[0].Histograms) == 0 {
return result[0].Samples[0].TimestampMs
}

return minInt64(result[0].Samples[0].TimestampMs, result[0].Histograms[0].Timestamp)
}

func minInt64(a, b int64) int64 {
if a < b {
return a
}
return b
}

func (resp *PrometheusResponse) GetStats() *PrometheusResponseStats {
Expand Down

0 comments on commit ece82d3

Please sign in to comment.