Module: NewRelic::TransactionAnalysis
- Included in:
- TransactionSample
- Defined in:
- lib/new_relic/transaction_analysis.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
59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 |
# File 'lib/new_relic/transaction_analysis.rb', line 59 def breakdown_data(limit = nil) metric_hash = {} each_segment 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 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
4 5 6 |
# File 'lib/new_relic/transaction_analysis.rb', line 4 def database_time time_percentage(/^Database\/.*/) end |
#render_time ⇒ Object
8 9 10 |
# File 'lib/new_relic/transaction_analysis.rb', line 8 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]
97 98 99 100 101 102 103 |
# File 'lib/new_relic/transaction_analysis.rb', line 97 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 |