Class: NewRelic::MetricParser::Controller

Inherits:
NewRelic::MetricParser show all
Defined in:
lib/new_relic/metric_parser/controller.rb

Constant Summary

Constants inherited from NewRelic::MetricParser

SEPARATOR

Instance Attribute Summary

Attributes inherited from NewRelic::MetricParser

#name

Instance Method Summary collapse

Methods inherited from NewRelic::MetricParser

#apdex_metric_path, #base_metric_name, #category, for_metric_named, #initialize, #last_segment, #legend_name, #method_missing, parse, #pie_chart_label, #segment_0, #segment_1, #segment_2, #segment_3, #segment_4, #segment_5, #segments, #tooltip_name

Constructor Details

This class inherits a constructor from NewRelic::MetricParser

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class NewRelic::MetricParser

Instance Method Details

#action_nameObject



15
16
17
18
19
20
21
# File 'lib/new_relic/metric_parser/controller.rb', line 15

def action_name
  if segments[-1] =~ /^\(other\)$/
    '(template only)'
  else
    segments[-1]
  end
end

#call_rate_suffixObject



55
56
57
# File 'lib/new_relic/metric_parser/controller.rb', line 55

def call_rate_suffix
  'rpm'
end

#controller_nameObject

If the controller name segments look like a file path, convert it to the controller class name. If it begins with a capital letter, assume it’s already a class name. We only expect a lower case letter with Rails, so we’ll be able to use camelize for that.



10
11
12
13
# File 'lib/new_relic/metric_parser/controller.rb', line 10

def controller_name
  path = segments[1..-2].join('/')
  path < 'a' ? path : path.camelize+"Controller"
end

#cpu_metricObject

return the cpu measuring equivalent. It may be nil since this metric was not present in earlier versions of the agent.



32
33
34
# File 'lib/new_relic/metric_parser/controller.rb', line 32

def cpu_metric
  Metric.lookup((["ControllerCPU"] + segments[1..-1]).join('/'), :create => false)
end

#developer_nameObject



23
24
25
# File 'lib/new_relic/metric_parser/controller.rb', line 23

def developer_name
  "#{controller_name}##{action_name}"
end

#is_controller?Boolean

Returns:

  • (Boolean)


3
# File 'lib/new_relic/metric_parser/controller.rb', line 3

def is_controller?; true; end

#is_transaction?Boolean

Returns:

  • (Boolean)


4
# File 'lib/new_relic/metric_parser/controller.rb', line 4

def is_transaction?; true; end

#is_web_transaction?Boolean

Returns:

  • (Boolean)


27
28
29
# File 'lib/new_relic/metric_parser/controller.rb', line 27

def is_web_transaction?
  true
end

#short_nameObject



36
37
38
39
40
41
42
43
# File 'lib/new_relic/metric_parser/controller.rb', line 36

def short_name
  # standard controller actions
  if segments.length > 1
    url
  else
    'All Controller Actions'
  end
end

#summary_metricsObject



59
60
61
# File 'lib/new_relic/metric_parser/controller.rb', line 59

def summary_metrics
  %w[HttpDispatcher]
end

#tt_pathObject

this is used to match transaction traces to controller actions. TT’s don’t have a preceding slash :P



51
52
53
# File 'lib/new_relic/metric_parser/controller.rb', line 51

def tt_path
  segments[1..-1].join('/')
end

#urlObject



45
46
47
# File 'lib/new_relic/metric_parser/controller.rb', line 45

def url
  '/' + segments[1..-1].join('/')
end