Module: SystemMetrics::MetricsHelper
- Defined in:
- app/helpers/system_metrics/metrics_helper.rb
Constant Summary collapse
- IDENTIFIER_ATTRS =
[:end_point, :layout, :identifier, :path, :name]
Instance Method Summary collapse
- #identifier(metric) ⇒ Object
- #page_title ⇒ Object
- #set_page_title(page_title) ⇒ Object
- #set_title(title) ⇒ Object
- #slow_threshold(metric) ⇒ Object
- #title ⇒ Object
Instance Method Details
#identifier(metric) ⇒ Object
21 22 23 24 |
# File 'app/helpers/system_metrics/metrics_helper.rb', line 21 def identifier(metric) attr = IDENTIFIER_ATTRS.find { |attr| metric.payload.include?(attr) && metric.payload[attr] != nil } attr.present? ? metric.payload[attr] : metric.name end |
#page_title ⇒ Object
17 18 19 |
# File 'app/helpers/system_metrics/metrics_helper.rb', line 17 def page_title content_for?(:page_title) ? content_for(:page_title) : '' end |
#set_page_title(page_title) ⇒ Object
13 14 15 |
# File 'app/helpers/system_metrics/metrics_helper.rb', line 13 def set_page_title(page_title) content_for(:page_title, page_title.to_s) end |
#set_title(title) ⇒ Object
5 6 7 |
# File 'app/helpers/system_metrics/metrics_helper.rb', line 5 def set_title(title) content_for(:title, title.to_s) end |
#slow_threshold(metric) ⇒ Object
26 27 28 29 30 31 32 33 34 |
# File 'app/helpers/system_metrics/metrics_helper.rb', line 26 def slow_threshold(metric) case metric.name when 'request.rack' then 500.0 when 'process_action.action_controller' then 450.0 when 'sql.active_record' then 150.0 when /render_[^\.]+\.action_view/ then 250.0 else 200.0 end end |
#title ⇒ Object
9 10 11 |
# File 'app/helpers/system_metrics/metrics_helper.rb', line 9 def title content_for?(:title) ? content_for(:title) : 'System Metrics' end |