Sha256: 805e5cfb5762cf12b9f2daa080b5d6b7d21e1c0e80512bcda125de3b438a262b

Contents?: true

Size: 884 Bytes

Versions: 2

Compression:

Stored size: 884 Bytes

Contents

module Octave
  module Helpers
    # 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
    module Controller
      # Measures the duration of the action.
      #
      # == Example
      #   around_action :measure_action, only: %i[create update destroy]
      def measure_action(&block)
        Octave.measure(measure_action_name, &block)
      end

      # The name of the metric. Default is
      # <tt>#{controller_name}.#{action_name}</tt>. Override this method if
      # you would like to specify your own name.
      def measure_action_name
        [controller_name, action_name].join(".")
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
octave-0.1.1 lib/octave/helpers/controller.rb
octave-0.1.0 lib/octave/helpers/controller.rb