@@ -236,27 +236,28 @@ def request(self, method, url, query_params=None, headers=None,
236
236
# log response body
237
237
logger .debug ("response body: %s" , r .data )
238
238
239
- data = self .decodeResponse (r .data )
240
239
http_metrics_request = [('method' , method ), ('url' , url ), ('query_params' , query_params ), ('headers' , headers ),
241
240
('body' , body ), ('post_params' , post_params )]
242
- if "message" not in data :
243
- self .http_metric .build_metric (transaction_id = self .configuration .metrics_transaction_id ,
244
- duration = data .get ("took" ),
245
- resource_path = url ,
246
- retry_statistics = copy .deepcopy (self .retrying .statistics ),
247
- error = False ,
248
- status = r .status ,
249
- status_code = r .status ,
250
- request = http_metrics_request )
251
- else :
252
- self .http_metric .build_metric (transaction_id = self .configuration .metrics_transaction_id ,
253
- duration = data .get ("took" ),
254
- resource_path = url ,
255
- retry_statistics = copy .deepcopy (self .retrying .statistics ),
256
- error = True ,
257
- status = r .status ,
258
- status_code = r .status ,
259
- request = http_metrics_request )
241
+
242
+ try :
243
+ data = self .decodeResponse (r .data )
244
+ duration = data .get ("took" )
245
+ if "message" not in data :
246
+ error = False
247
+ else :
248
+ error = True
249
+ except :
250
+ duration = None
251
+ error = True
252
+
253
+ self .http_metric .build_metric (transaction_id = self .configuration .metrics_transaction_id ,
254
+ duration = duration ,
255
+ resource_path = url ,
256
+ retry_statistics = copy .deepcopy (self .retrying .statistics ),
257
+ error = error ,
258
+ status = r .status ,
259
+ status_code = r .status ,
260
+ request = http_metrics_request )
260
261
261
262
should_retry = self .__checkHttpCode__ (r .status )
262
263
if should_retry :
0 commit comments