Sha256: 59db04f9c15a47028da914d2b5a31f50435a741aa82a16727919b8123ba80efe

Contents?: true

Size: 1.8 KB

Versions: 80

Compression:

Stored size: 1.8 KB

Contents

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

80 entries across 80 versions & 5 rubygems

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