Class: NewRelic::TransactionAnalysis::SegmentSummary

Inherits:
Object
  • Object
show all
Defined in:
lib/new_relic/transaction_analysis/segment_summary.rb

Overview

summarizes performance data for all calls to segments with the same metric_name

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(metric_name, sample) ⇒ SegmentSummary

Returns a new instance of SegmentSummary.



7
8
9
10
11
12
# File 'lib/new_relic/transaction_analysis/segment_summary.rb', line 7

def initialize(metric_name, sample)
  @metric_name = metric_name
  @total_time, @exclusive_time, @call_count = 0,0,0
  @sample = sample
  @current_nest_count = 0
end

Instance Attribute Details

#call_countObject

Returns the value of attribute call_count.



6
7
8
# File 'lib/new_relic/transaction_analysis/segment_summary.rb', line 6

def call_count
  @call_count
end

#current_nest_countObject

Returns the value of attribute current_nest_count.



6
7
8
# File 'lib/new_relic/transaction_analysis/segment_summary.rb', line 6

def current_nest_count
  @current_nest_count
end

#exclusive_timeObject

Returns the value of attribute exclusive_time.



6
7
8
# File 'lib/new_relic/transaction_analysis/segment_summary.rb', line 6

def exclusive_time
  @exclusive_time
end

#metric_nameObject

Returns the value of attribute metric_name.



6
7
8
# File 'lib/new_relic/transaction_analysis/segment_summary.rb', line 6

def metric_name
  @metric_name
end

#total_timeObject

Returns the value of attribute total_time.



6
7
8
# File 'lib/new_relic/transaction_analysis/segment_summary.rb', line 6

def total_time
  @total_time
end

Instance Method Details

#<<(segment) ⇒ Object



14
15
16
17
18
19
20
21
22
23
# File 'lib/new_relic/transaction_analysis/segment_summary.rb', line 14

def <<(segment)
  if metric_name != segment.metric_name
    raise ArgumentError, "Metric Name Mismatch: #{segment.metric_name} != #{metric_name}"
  end

  # a nested segment should use the sum of the top level totals
  @total_time += segment.duration if current_nest_count == 0
  @exclusive_time += segment.exclusive_duration
  @call_count += 1
end

#average_exclusive_timeObject



29
30
31
# File 'lib/new_relic/transaction_analysis/segment_summary.rb', line 29

def average_exclusive_time
  @exclusive_time / @call_count
end

#average_timeObject



25
26
27
# File 'lib/new_relic/transaction_analysis/segment_summary.rb', line 25

def average_time
  @total_time / @call_count
end

#exclusive_time_percentageObject



33
34
35
36
# File 'lib/new_relic/transaction_analysis/segment_summary.rb', line 33

def exclusive_time_percentage
  return 0 unless @exclusive_time && @sample.duration && @sample.duration > 0
  @exclusive_time / @sample.duration
end

#total_time_percentageObject



38
39
40
41
# File 'lib/new_relic/transaction_analysis/segment_summary.rb', line 38

def total_time_percentage
  return 0 unless @total_time && @sample.duration && @sample.duration > 0
  @total_time / @sample.duration
end

#ui_nameObject



43
44
45
46
# File 'lib/new_relic/transaction_analysis/segment_summary.rb', line 43

def ui_name
  return @metric_name if @metric_name == 'Remainder'
  NewRelic::MetricParser::MetricParser.parse(@metric_name).developer_name
end