Sha256: ace83e2853ce8b8ff7fb8aa657c229952a34ec6d17406560c549f9bcd1fc11a9

Contents?: true

Size: 1.47 KB

Versions: 18

Compression:

Stored size: 1.47 KB

Contents

require 'active_support/core_ext/module/attr_internal'
require 'superstore/log_subscriber'

module Superstore
  module Railties # :nodoc:
    module ControllerRuntime #:nodoc:
      extend ActiveSupport::Concern

      module ClassMethods # :nodoc:
        def log_process_action(payload)
          messages, cassandra_object_runtime = super, payload[:cassandra_object_runtime]
          if cassandra_object_runtime.to_i > 0
            messages << ("Superstore: %.1fms" % cassandra_object_runtime.to_f)
          end
          messages
        end
      end

      #private

        attr_internal :cassandra_object_runtime

        def process_action(action, *args)
          # We also need to reset the runtime before each action
          # because of queries in middleware or in cases we are streaming
          # and it won't be cleaned up by the method below.
          Superstore::LogSubscriber.reset_runtime
          super
        end

        def cleanup_view_runtime
          runtime_before_render = Superstore::LogSubscriber.reset_runtime
          runtime = super
          runtime_after_render = Superstore::LogSubscriber.reset_runtime
          self.cassandra_object_runtime = runtime_before_render + runtime_after_render
          runtime - runtime_after_render
        end

        def append_info_to_payload(payload)
          super
          payload[:cassandra_object_runtime] = (cassandra_object_runtime || 0) + Superstore::LogSubscriber.reset_runtime
        end
    end
  end
end

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
superstore-1.2.0 lib/superstore/railties/controller_runtime.rb
superstore-1.1.4 lib/superstore/railties/controller_runtime.rb
superstore-1.1.3 lib/superstore/railties/controller_runtime.rb
superstore-1.1.2 lib/superstore/railties/controller_runtime.rb
superstore-1.1.1 lib/superstore/railties/controller_runtime.rb
superstore-1.1.0 lib/superstore/railties/controller_runtime.rb
superstore-1.0.12 lib/superstore/railties/controller_runtime.rb
superstore-1.0.11 lib/superstore/railties/controller_runtime.rb
superstore-1.0.10 lib/superstore/railties/controller_runtime.rb
superstore-1.0.9 lib/superstore/railties/controller_runtime.rb
superstore-1.0.8 lib/superstore/railties/controller_runtime.rb
superstore-1.0.7 lib/superstore/railties/controller_runtime.rb
superstore-1.0.6 lib/superstore/railties/controller_runtime.rb
superstore-1.0.5 lib/superstore/railties/controller_runtime.rb
superstore-1.0.4 lib/superstore/railties/controller_runtime.rb
superstore-1.0.3 lib/superstore/railties/controller_runtime.rb
superstore-1.0.2 lib/superstore/railties/controller_runtime.rb
superstore-1.0.0 lib/superstore/railties/controller_runtime.rb