1
1
module Gitlab ::Prometheus ::Queries
2
2
class AdditionalMetricsQuery < BaseQuery
3
3
def query ( environment_id )
4
- query_processor = method ( :process_query ) . curry [ query_context ( environment_id ) ]
4
+ environment = Environment . find_by ( id : environment_id )
5
+ query_context = {
6
+ environment_slug : environment . slug ,
7
+ environment_filter : %{container_name!="POD",environment="#{ environment . slug } "} ,
8
+ timeframe_start : 8 . hours . ago . to_f ,
9
+ timeframe_end : Time . now . to_f
10
+ }
11
+
12
+ query_metrics ( query_context )
13
+ end
14
+
15
+ protected
16
+
17
+ def query_metrics ( query_context )
18
+ query_processor = method ( :process_query ) . curry [ query_context ]
5
19
6
20
matched_metrics . map do |group |
7
21
metrics = group . metrics . map do |metric |
@@ -22,16 +36,6 @@ def query(environment_id)
22
36
23
37
private
24
38
25
- def query_context ( environment_id )
26
- environment = Environment . find_by ( id : environment_id )
27
- {
28
- environment_slug : environment . slug ,
29
- environment_filter : %{container_name!="POD",environment="#{ environment . slug } "} ,
30
- timeframe_start : 8 . hours . ago . to_f ,
31
- timeframe_end : Time . now . to_f
32
- }
33
- end
34
-
35
39
def process_query ( context , query )
36
40
query_with_result = query . dup
37
41
query_with_result [ :result ] =
0 commit comments