Sha256: 21c0fca4469880337b04ec6243b37a7d76443a9ca66f658d9ab1548ed921bdaa

Contents?: true

Size: 1.96 KB

Versions: 38

Compression:

Stored size: 1.96 KB

Contents

# encoding: utf-8
# This file is distributed under New Relic's license terms.
# See https://github.com/newrelic/rpm/blob/master/LICENSE for complete details.

require 'new_relic/metric_parser'
module NewRelic
  module MetricParser
    class View < NewRelic::MetricParser::MetricParser
      def is_view?; true; end

      def is_render?
        segments.last == "Rendering"
      end
      def is_compiler?
        segments.last == "Compile"
      end
      def pie_chart_label
        case segments.last
        when "Rendering"
          "#{file_name(segments[-2])} Template"
        when "Partial"
          "#{file_name(segments[-2])} Partial"
        when "Collection"
          "#{file_name(segments[-2])} Collection"
        when ".rhtml Processing"
          "ERB compilation"
        else
          segments[1..-1]
        end
      end
      def template_label
        case segments.last
        when "Rendering"
          "#{file_name(segments[1..-2].join(NewRelic::MetricParser::MetricParser::SEPARATOR))} Template"
        when "Partial"
          "#{file_name(segments[1..-2].join(NewRelic::MetricParser::MetricParser::SEPARATOR))} Partial"
        when "Collection"
          "#{file_name(segments[1..-2].join(NewRelic::MetricParser::MetricParser::SEPARATOR))} Collection"
        when ".rhtml Processing"
          "ERB compilation"
        else
          segments[1..-1].join("/")
        end
      end

      def short_name
        segments[1..-2].join(NewRelic::MetricParser::MetricParser::SEPARATOR)
      end

      def controller_name
        template_label
      end

      def action_name
        # Strip the extension
        segments[-2].gsub(/\..*$/, "")
      end

      def developer_name
        template_label
      end

      def url
        '/' + file_name(segments[1..-2].join('/'))
      end
      private
      def file_name(path)
        label = path.gsub /\.html\.rhtml/, '.rhtml'
        label = segments[1] if label.empty?
        label
      end
    end
  end
end

Version data entries

38 entries across 38 versions & 1 rubygems

Version Path
newrelic_rpm-3.9.1.236 vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/view.rb
newrelic_rpm-3.9.0.229 vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/view.rb
newrelic_rpm-3.8.1.221 vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/view.rb
newrelic_rpm-3.8.0.218 vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/view.rb
newrelic_rpm-3.7.3.204 vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/view.rb
newrelic_rpm-3.7.3.199 vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/view.rb
newrelic_rpm-3.7.2.195 vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/view.rb
newrelic_rpm-3.7.2.192 vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/view.rb
newrelic_rpm-3.7.2.190.beta vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/view.rb
newrelic_rpm-3.7.1.188 vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/view.rb
newrelic_rpm-3.7.1.182 vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/view.rb
newrelic_rpm-3.7.1.180 vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/view.rb
newrelic_rpm-3.7.0.177 vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/view.rb
newrelic_rpm-3.7.0.174.beta vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/view.rb
newrelic_rpm-3.6.9.171 vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/view.rb
newrelic_rpm-3.6.8.168 vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/view.rb
newrelic_rpm-3.6.8.164 vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/view.rb
newrelic_rpm-3.6.7.159 vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/view.rb
newrelic_rpm-3.6.7.159.beta vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/view.rb
newrelic_rpm-3.6.7.152 vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/view.rb