Module: Octave::Helpers::Controller

Defined in:
lib/octave/helpers/controller.rb

Overview

Helpers to include in your Rails controllers to automatically collect metrics on how long it takes to complete an action.

Example

class PostsController < ActionController::Base
  include Octave::Helpers::Controller

  around_action :measure_action
end

Instance Method Summary collapse

Instance Method Details

#measure_action(&block) ⇒ Object

Measures the duration of the action.

Example

around_action :measure_action, only: %i[create update destroy]


17
18
19
# File 'lib/octave/helpers/controller.rb', line 17

def measure_action(&block)
  Octave.measure(measure_action_name, &block)
end

#measure_action_nameObject

The name of the metric. Default is #{controller_name}.#{action_name}. Override this method if you would like to specify your own name.



24
25
26
# File 'lib/octave/helpers/controller.rb', line 24

def measure_action_name
  [controller_name, action_name].join(".")
end