@@ -64,20 +64,21 @@ def upload_class(self, class_name):
6464 def metric_dimensions (self ):
6565 return [{"Name" : "APIName" , "Value" : self .name }, {"Name" : "APIID" , "Value" : self .id }]
6666
67- def post_request_metrics (self , status_code , start_time , prediction_value = None ):
68- metrics_list = []
69- metrics_list . append ( self .status_code_metric ( status_code ) )
67+ def post_latency_metrics (self , status_code , start_time ):
68+ metrics = [self . status_code_metric ( status_code ), self . latency_metric ( start_time ) ]
69+ self .post_metrics ( metrics )
7070
71+ def post_tracker_metrics (self , prediction_value = None ):
7172 if prediction_value is not None :
72- metrics_list .append (self .prediction_metrics (prediction_value ))
73-
74- metrics_list .append (self .latency_metric (start_time ))
73+ metrics = [self .prediction_metrics (prediction_value )]
74+ self .post_metrics (metrics )
7575
76+ def post_metrics (self , metrics ):
7677 try :
7778 if self .statsd is None :
7879 raise CortexException ("statsd client not initialized" ) # unexpected
7980
80- for metric in metrics_list :
81+ for metric in metrics :
8182 tags = ["{}:{}" .format (dim ["Name" ], dim ["Value" ]) for dim in metric ["Dimensions" ]]
8283 if metric .get ("Unit" ) == "Count" :
8384 self .statsd .increment (metric ["MetricName" ], value = metric ["Value" ], tags = tags )
0 commit comments