@@ -9,44 +9,9 @@ import (
9
9
"github.com/prometheus/common/model"
10
10
)
11
11
12
- func getFirstValueOfVector (query string , promInstance PrometheusInstance ) (float64 , error ) {
13
- result , err := promInstance .Query (query )
14
- if err != nil {
15
- return 0 , err
16
- }
17
-
18
- val , err := GetFirstValueOfPrometheusVector (result )
19
- if err != nil {
20
- return 0 , err
21
- }
22
-
23
- return val , nil
24
- }
25
-
26
- func getBuckets (query string , promInstance PrometheusInstance ) ([]Bucket , error ) {
27
- result , err := promInstance .Query (query )
28
- if err != nil {
29
- return nil , err
30
- }
31
-
32
- res , ok := result .(model.Vector )
33
- if ! ok {
34
- return nil , errors .New ("could not convert result to vector" )
35
- }
36
-
37
- buckets := make ([]Bucket , 0 , len (res ))
38
-
39
- for _ , sample := range res {
40
- le := sample .Metric ["le" ]
41
- val := float64 (sample .Value )
42
- bucket := Bucket {
43
- Le : string (le ),
44
- Val : int (val ),
45
- }
46
- buckets = append (buckets , bucket )
47
- }
48
-
49
- return buckets , nil
12
+ type Bucket struct {
13
+ Le string
14
+ Val int
50
15
}
51
16
52
17
func GetReloadCount (promInstance PrometheusInstance , ngfPodName string ) (float64 , error ) {
@@ -304,7 +269,42 @@ func CreateResponseChecker(url, address string, requestTimeout time.Duration) fu
304
269
}
305
270
}
306
271
307
- type Bucket struct {
308
- Le string
309
- Val int
272
+ func getFirstValueOfVector (query string , promInstance PrometheusInstance ) (float64 , error ) {
273
+ result , err := promInstance .Query (query )
274
+ if err != nil {
275
+ return 0 , err
276
+ }
277
+
278
+ val , err := GetFirstValueOfPrometheusVector (result )
279
+ if err != nil {
280
+ return 0 , err
281
+ }
282
+
283
+ return val , nil
284
+ }
285
+
286
+ func getBuckets (query string , promInstance PrometheusInstance ) ([]Bucket , error ) {
287
+ result , err := promInstance .Query (query )
288
+ if err != nil {
289
+ return nil , err
290
+ }
291
+
292
+ res , ok := result .(model.Vector )
293
+ if ! ok {
294
+ return nil , errors .New ("could not convert result to vector" )
295
+ }
296
+
297
+ buckets := make ([]Bucket , 0 , len (res ))
298
+
299
+ for _ , sample := range res {
300
+ le := sample .Metric ["le" ]
301
+ val := float64 (sample .Value )
302
+ bucket := Bucket {
303
+ Le : string (le ),
304
+ Val : int (val ),
305
+ }
306
+ buckets = append (buckets , bucket )
307
+ }
308
+
309
+ return buckets , nil
310
310
}
0 commit comments