mirror of
https://github.com/prometheus/prometheus.git
synced 2024-11-09 23:24:05 -08:00
promql: Support histogram in value string representation
Signed-off-by: beorn7 <beorn@grafana.com>
This commit is contained in:
parent
4c28d9fac7
commit
9b30ca2598
|
@ -2455,10 +2455,11 @@ func TestSparseHistogramRate(t *testing.T) {
|
|||
require.NoError(t, test.Run())
|
||||
engine := test.QueryEngine()
|
||||
|
||||
queryString := fmt.Sprintf("rate(%s[1m])", seriesName)
|
||||
//queryString := fmt.Sprintf("rate(%s[1m])", seriesName)
|
||||
queryString := fmt.Sprintf("%s", seriesName)
|
||||
qry, err := engine.NewInstantQuery(test.Queryable(), queryString, timestamp.Time(int64(5*time.Minute/time.Millisecond)))
|
||||
require.NoError(t, err)
|
||||
res := qry.Exec(test.Context())
|
||||
require.NoError(t, res.Err)
|
||||
// fmt.Println(res)
|
||||
fmt.Println(res)
|
||||
}
|
||||
|
|
|
@ -87,9 +87,13 @@ type Point struct {
|
|||
}
|
||||
|
||||
func (p Point) String() string {
|
||||
// TODO(beorn7): Support Histogram.
|
||||
v := strconv.FormatFloat(p.V, 'f', -1, 64)
|
||||
return fmt.Sprintf("%v @[%v]", v, p.T)
|
||||
var s string
|
||||
if p.H != nil {
|
||||
s = p.H.String()
|
||||
} else {
|
||||
s = strconv.FormatFloat(p.V, 'f', -1, 64)
|
||||
}
|
||||
return fmt.Sprintf("%s @[%v]", s, p.T)
|
||||
}
|
||||
|
||||
// MarshalJSON implements json.Marshaler.
|
||||
|
|
|
@ -80,8 +80,12 @@ func (b *MemoizedSeriesIterator) Seek(t int64) bool {
|
|||
if !b.ok {
|
||||
return false
|
||||
}
|
||||
if b.it.ChunkEncoding() == chunkenc.EncHistogram {
|
||||
b.lastTime, _ = b.it.AtHistogram()
|
||||
} else {
|
||||
b.lastTime, _ = b.it.At()
|
||||
}
|
||||
}
|
||||
|
||||
if b.lastTime >= t {
|
||||
return true
|
||||
|
@ -102,12 +106,20 @@ func (b *MemoizedSeriesIterator) Next() bool {
|
|||
}
|
||||
|
||||
// Keep track of the previous element.
|
||||
if b.it.ChunkEncoding() == chunkenc.EncHistogram {
|
||||
b.prevTime, b.prev
|
||||
} else {
|
||||
b.prevTime, b.prevValue = b.it.At()
|
||||
}
|
||||
|
||||
b.ok = b.it.Next()
|
||||
if b.ok {
|
||||
if b.it.ChunkEncoding() == chunkenc.EncHistogram {
|
||||
b.lastTime, _ = b.it.AtHistogram()
|
||||
} else {
|
||||
b.lastTime, _ = b.it.At()
|
||||
}
|
||||
}
|
||||
|
||||
return b.ok
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue