#NEWLINE# def parse_xml_jtl( self , granularity ) : #NEWLINE# #INDENT# "\n    Parse Jmeter workload output in XML format and extract overall and per transaction data and key statistics\n\n    :param string granularity: The time period over which to aggregate and average the raw data. Valid values are 'hour', 'minute' or 'second'\n    :return: status of the metric parse\n    " #NEWLINE# data = defaultdict ( list ) #NEWLINE# processed_data = defaultdict ( ( lambda : defaultdict ( ( lambda : defaultdict ( list ) ) ) ) ) #NEWLINE# for input_file in self . infile_list : #NEWLINE# #INDENT# logger . info ( 'Processing : %s' , input_file ) #NEWLINE# timestamp_format = None #NEWLINE# tree = ElementTree . parse ( input_file ) #NEWLINE# samples = ( tree . findall ( './httpSample' ) + tree . findall ( './sample' ) ) #NEWLINE# for sample in samples : #NEWLINE# #INDENT# if ( ( not timestamp_format ) or ( timestamp_format == 'unknown' ) ) : #NEWLINE# #INDENT# timestamp_format = naarad . utils . detect_timestamp_format ( sample . get ( 'ts' ) ) #NEWLINE# #UNINDENT# if ( timestamp_format == 'unknown' ) : #NEWLINE# #INDENT# continue #NEWLINE# #UNINDENT# ts = naarad . utils . get_standardized_timestamp ( sample . get ( 'ts' ) , timestamp_format ) #NEWLINE# if ( ts == ( - 1 ) ) : #NEWLINE# #INDENT# continue #NEWLINE# #UNINDENT# ts = naarad . utils . reconcile_timezones ( ts , self . timezone , self . graph_timezone ) #NEWLINE# ( aggregate_timestamp , averaging_factor ) = self . get_aggregation_timestamp ( ts , granularity ) #NEWLINE# self . aggregate_count_over_time ( processed_data , sample , [ self . _sanitize_label ( sample . get ( 'lb' ) ) , 'Overall_Summary' ] , aggregate_timestamp ) #NEWLINE# self . aggregate_values_over_time ( processed_data , sample , [ self . _sanitize_label ( sample . get ( 'lb' ) ) , 'Overall_Summary' ] , [ 't' , 'by' ] , aggregate_timestamp ) #NEWLINE# logger . info ( 'Finished parsing : %s' , input_file ) #NEWLINE# #UNINDENT# #UNINDENT# logger . info ( 'Processing metrics for output to csv' ) #NEWLINE# self . average_values_for_plot ( processed_data , data , averaging_factor ) #NEWLINE# logger . info ( 'Writing time series csv' ) #NEWLINE# for csv in data . keys ( ) : #NEWLINE# #INDENT# self . csv_files . append ( csv ) #NEWLINE# with open ( csv , 'w' ) as csvf : #NEWLINE# #INDENT# csvf . write ( '\n' . join ( sorted ( data [ csv ] ) ) ) #NEWLINE# #UNINDENT# #UNINDENT# logger . info ( 'Processing raw data for stats' ) #NEWLINE# self . calculate_key_stats ( processed_data ) #NEWLINE# return True