8
8
from SearchAPI .CMR .SubQuery import CMRSubQuery
9
9
from flask import request
10
10
11
- import boto3
12
-
13
11
14
12
class CMRQuery :
15
13
def __init__ (self , req_fields , params = None , max_results = None ):
@@ -70,12 +68,10 @@ def get_results(self):
70
68
if self .is_out_of_time ():
71
69
logging .warning ('Query ran too long, terminating' )
72
70
logging .warning (self .params )
73
- self .log_subquery_time ()
74
71
return
75
72
76
73
if self .max_results_reached ():
77
74
logging .debug ('Max results reached, terminating' )
78
- self .log_subquery_time ()
79
75
return
80
76
81
77
if result is None :
@@ -87,11 +83,9 @@ def get_results(self):
87
83
# it's a little silly but run this check again here so we don't accidentally fetch an extra page
88
84
if self .max_results_reached ():
89
85
logging .debug ('Max results reached, terminating' )
90
- self .log_subquery_time ()
91
86
return
92
87
93
88
logging .debug ('End of available results reached' )
94
- self .log_subquery_time ()
95
89
96
90
def is_out_of_time (self ):
97
91
return time .time () > self .cutoff_time
@@ -101,37 +95,6 @@ def max_results_reached(self):
101
95
self .max_results is not None and
102
96
self .result_counter >= self .max_results
103
97
)
104
-
105
-
106
-
107
- def log_subquery_time (self ):
108
- subquery_times = []
109
- for subquery in self .sub_queries :
110
- subquery_times .extend (subquery .query_times )
111
- try :
112
- if request .asf_config ['cloudwatch_metrics' ]:
113
- logging .debug ('Logging subquery run time to cloudwatch metrics' )
114
- cloudwatch = boto3 .client ('cloudwatch' )
115
- cloudwatch .put_metric_data (
116
- MetricData = [
117
- {
118
- 'MetricName' : 'SubqueryRuntime' ,
119
- 'Dimensions' : [
120
- {
121
- 'Name' : 'maturity' ,
122
- 'Value' : request .asf_base_maturity
123
- }
124
- ],
125
- 'Unit' : 'None' ,
126
- 'Values' : subquery_times
127
- }
128
- ],
129
- Namespace = 'SearchAPI'
130
- )
131
- except Exception as e :
132
- logging .exception (f'Failure during subquery run time logging: { e } ' )
133
-
134
-
135
98
136
99
def subquery_list_from (params ):
137
100
"""
0 commit comments