Module: NewRelic::TransactionAnalysis
- Included in:
- TransactionSample
- Defined in:
- lib/new_relic/transaction_analysis.rb,
lib/new_relic/transaction_analysis/segment_summary.rb
Defined Under Namespace
Classes: SegmentSummary
Instance Method Summary collapse
-
#breakdown_data(limit = nil) ⇒ Object
return the data that breaks down the performance of the transaction as an array of SegmentSummary objects.
- #database_time ⇒ Object
- #render_time ⇒ Object
-
#sql_segments(show_non_sql_segments = true) ⇒ Object
return an array of sql statements executed by this transaction each element in the array contains [sql, parent_segment_metric_name, duration].
Instance Method Details
#breakdown_data(limit = nil) ⇒ Object
return the data that breaks down the performance of the transaction as an array of SegmentSummary objects. If a limit is specified, then limit the data set to the top n
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/new_relic/transaction_analysis.rb', line 16 def breakdown_data(limit = nil) metric_hash = {} each_segment_with_nest_tracking do |segment| unless segment == root_segment metric_name = segment.metric_name metric_hash[metric_name] ||= SegmentSummary.new(metric_name, self) metric_hash[metric_name] << segment metric_hash[metric_name] end end data = metric_hash.values data.sort! do |x,y| y.exclusive_time <=> x.exclusive_time end if limit && data.length > limit data = data[0..limit - 1] end # add one last segment for the remaining time if any remainder = duration data.each do |segment| remainder -= segment.exclusive_time end if (remainder*1000).round > 0 remainder_summary = SegmentSummary.new('Remainder', self) remainder_summary.total_time = remainder_summary.exclusive_time = remainder remainder_summary.call_count = 1 data << remainder_summary end data end |
#database_time ⇒ Object
5 6 7 |
# File 'lib/new_relic/transaction_analysis.rb', line 5 def database_time time_percentage(/^Database\/.*/) end |
#render_time ⇒ Object
9 10 11 |
# File 'lib/new_relic/transaction_analysis.rb', line 9 def render_time time_percentage(/^View\/.*/) end |
#sql_segments(show_non_sql_segments = true) ⇒ Object
return an array of sql statements executed by this transaction each element in the array contains [sql, parent_segment_metric_name, duration]
55 56 57 58 59 60 61 |
# File 'lib/new_relic/transaction_analysis.rb', line 55 def sql_segments(show_non_sql_segments = true) segments = [] each_segment do |segment| segments << segment if segment[:sql] || segment[:sql_obfuscated] || (show_non_sql_segments && segment[:key]) end segments end |