Sha256: fddf0c248c37f66653b7191cc5f9f7634df43a91201bf42b979e972f14284140

Contents?: true

Size: 1.69 KB

Versions: 20

Compression:

Stored size: 1.69 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)
        return if RailsPerformance.skip
        return if CurrentRequest.current.data

        # TODO do we need this new?
        event = ActiveSupport::Notifications::Event.new(event_name, started, finished, event_id, payload)

        return if RailsPerformance.ignored_endpoints.include? "#{event.payload[:controller]}##{event.payload[:action]}"

        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,
          exception: event.payload[:exception],
          exception_object: event.payload[:exception_object]
        }

        # pass the record to Thread.current
        # and saves later in middleware
        CurrentRequest.current.data = record
      end
    end
  end
end

Version data entries

20 entries across 20 versions & 1 rubygems

Version Path
rails_performance-1.2.2 lib/rails_performance/instrument/metrics_collector.rb
rails_performance-1.2.1 lib/rails_performance/instrument/metrics_collector.rb
rails_performance-1.2.0 lib/rails_performance/instrument/metrics_collector.rb
rails_performance-1.2.0.alpha5 lib/rails_performance/instrument/metrics_collector.rb
rails_performance-1.2.0.alpha4 lib/rails_performance/instrument/metrics_collector.rb
rails_performance-1.2.0.alpha3 lib/rails_performance/instrument/metrics_collector.rb
rails_performance-1.2.0.alpha2 lib/rails_performance/instrument/metrics_collector.rb
rails_performance-1.2.0.alpha1 lib/rails_performance/instrument/metrics_collector.rb
rails_performance-1.1.0 lib/rails_performance/instrument/metrics_collector.rb
rails_performance-1.0.5.3 lib/rails_performance/instrument/metrics_collector.rb
rails_performance-1.0.5.2 lib/rails_performance/instrument/metrics_collector.rb
rails_performance-1.0.5.1 lib/rails_performance/instrument/metrics_collector.rb
rails_performance-1.0.5 lib/rails_performance/instrument/metrics_collector.rb
rails_performance-1.0.4 lib/rails_performance/instrument/metrics_collector.rb
rails_performance-1.0.3 lib/rails_performance/instrument/metrics_collector.rb
rails_performance-1.0.2 lib/rails_performance/instrument/metrics_collector.rb
rails_performance-1.0.1 lib/rails_performance/instrument/metrics_collector.rb
rails_performance-1.0.0 lib/rails_performance/instrument/metrics_collector.rb
rails_performance-1.0.0.beta5 lib/rails_performance/instrument/metrics_collector.rb
rails_performance-1.0.0.beta4 lib/rails_performance/instrument/metrics_collector.rb