Sha256: 4db6b0272eb633d741bf66478685e0188c7837314950f3c5a47340dcd27d4e9c

Contents?: true

Size: 1.5 KB

Versions: 87

Compression:

Stored size: 1.5 KB

Contents

module NewRelic
  module TransactionAnalysis
    # summarizes performance data for all calls to segments
    # with the same metric_name
    class SegmentSummary
      attr_accessor :metric_name, :total_time, :exclusive_time, :call_count, :current_nest_count
      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

      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

      def average_time
        @total_time / @call_count
      end

      def average_exclusive_time
        @exclusive_time / @call_count
      end

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

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

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

Version data entries

87 entries across 87 versions & 5 rubygems

Version Path
wd_newrelic_rpm-3.5.8 lib/new_relic/transaction_analysis/segment_summary.rb
sundawg_newrelic_rpm-3.5.8.2 lib/new_relic/transaction_analysis/segment_summary.rb
sundawg_newrelic_rpm-3.5.8.1 lib/new_relic/transaction_analysis/segment_summary.rb
newrelic_rpm-3.5.8.72 lib/new_relic/transaction_analysis/segment_summary.rb
newrelic_rpm-3.5.8.70 lib/new_relic/transaction_analysis/segment_summary.rb
newrelic_rpm-3.5.8.64.beta lib/new_relic/transaction_analysis/segment_summary.rb
newrelic_rpm-3.5.7.59 lib/new_relic/transaction_analysis/segment_summary.rb
newrelic_rpm-3.5.7.59.beta lib/new_relic/transaction_analysis/segment_summary.rb
newrelic_rpm-3.5.7.58.beta lib/new_relic/transaction_analysis/segment_summary.rb
wd_newrelic_rpm-3.5.6 lib/new_relic/transaction_analysis/segment_summary.rb
newrelic_rpm-3.5.7.57.beta lib/new_relic/transaction_analysis/segment_summary.rb
newrelic_rpm-3.5.6.55 lib/new_relic/transaction_analysis/segment_summary.rb
newrelic_rpm-3.5.6.48.beta lib/new_relic/transaction_analysis/segment_summary.rb
newrelic_rpm-3.5.6.46.beta lib/new_relic/transaction_analysis/segment_summary.rb
newrelic_rpm-3.5.6.42.beta lib/new_relic/transaction_analysis/segment_summary.rb
newrelic_rpm-3.5.5.39.beta lib/new_relic/transaction_analysis/segment_summary.rb
wd_newrelic_rpm-3.5.5 lib/new_relic/transaction_analysis/segment_summary.rb
newrelic_rpm-3.5.5.38 lib/new_relic/transaction_analysis/segment_summary.rb
newrelic_rpm-3.5.5.540.dev lib/new_relic/transaction_analysis/segment_summary.rb
newrelic_rpm-3.5.4.35.beta lib/new_relic/transaction_analysis/segment_summary.rb