-
Notifications
You must be signed in to change notification settings - Fork 786
/
custom.go
49 lines (42 loc) · 967 Bytes
/
custom.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
package client
import (
"encoding/binary"
"github.com/cortexproject/cortex/pkg/chunk/encoding"
)
// ChunksCount returns the number of chunks in response.
func (m *QueryStreamResponse) ChunksCount() int {
if len(m.Chunkseries) == 0 {
return 0
}
count := 0
for _, entry := range m.Chunkseries {
count += len(entry.Chunks)
}
return count
}
// ChunksSize returns the size of all chunks in the response.
func (m *QueryStreamResponse) ChunksSize() int {
if len(m.Chunkseries) == 0 {
return 0
}
size := 0
for _, entry := range m.Chunkseries {
for _, chunk := range entry.Chunks {
size += chunk.Size()
}
}
return size
}
func (m *QueryStreamResponse) SamplesCount() (count int) {
for _, ts := range m.Timeseries {
count += len(ts.Samples)
}
for _, cs := range m.Chunkseries {
for _, c := range cs.Chunks {
if c.Encoding == int32(encoding.PrometheusXorChunk) {
count += int(binary.BigEndian.Uint16(c.Data))
}
}
}
return
}