Sha256: 8a3927b98a9b0beebe304dc230b4549a04a6731d42be78477cb541a412d5d695

Contents?: true

Size: 1.32 KB

Versions: 8

Compression:

Stored size: 1.32 KB

Contents

module RailsPerformance
  module Instrument
    class MetricsCollector
      # payload
      # {
      #   controller: "PostsController",
      #   action: "index",
      #   params: {"action" => "index", "controller" => "posts"},
      #   headers: #<ActionDispatch::Http::Headers:0x0055a67a519b88>,
      #   format: :html,
      #   method: "GET",
      #   path: "/posts",
      #   status: 200,
      #   view_runtime: 46.848,
      #   db_runtime: 0.157
      # }

      def call(event_name, started, finished, event_id, payload)
        event = ActiveSupport::Notifications::Event.new(event_name, started, finished, event_id, payload)

        return if event.payload[:path] =~ /^\/rails\/performance/

        record = {
          controller: event.payload[:controller],
          action: event.payload[:action],
          format: event.payload[:format],
          status: event.payload[:status],
          datetime: finished.strftime(RailsPerformance::FORMAT),
          datetimei: finished.to_i,
          method: event.payload[:method],
          path: event.payload[:path],
          view_runtime: event.payload[:view_runtime],
          db_runtime: event.payload[:db_runtime],
          duration: event.duration
        }

        CurrentRequest.current.record = record
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
rails_performance-0.9.6 lib/rails_performance/instrument/metrics_collector.rb
rails_performance-0.9.5 lib/rails_performance/instrument/metrics_collector.rb
rails_performance-0.9.4 lib/rails_performance/instrument/metrics_collector.rb
rails_performance-0.9.3 lib/rails_performance/instrument/metrics_collector.rb
rails_performance-0.9.2 lib/rails_performance/instrument/metrics_collector.rb
rails_performance-0.9.1 lib/rails_performance/instrument/metrics_collector.rb
rails_performance-0.9.0.1 lib/rails_performance/instrument/metrics_collector.rb
rails_performance-0.9.0 lib/rails_performance/instrument/metrics_collector.rb