Class: PigCI::ProfilerEngine::Rails

Inherits:
PigCI::ProfilerEngine show all
Defined in:
lib/pig_ci/profiler_engine/rails.rb

Overview

This subscribes to the ActiveSupport::Notifications and passes it onto our profilers.

Instance Attribute Summary

Attributes inherited from PigCI::ProfilerEngine

#profilers, #reports, #request_captured, #request_key

Instance Method Summary collapse

Methods inherited from PigCI::ProfilerEngine

#request_captured!, #request_captured?, #request_key?

Constructor Details

#initialize(profilers: nil, reports: nil) ⇒ Rails

Returns a new instance of Rails.


3
4
5
6
7
8
9
10
11
12
13
14
15
# File 'lib/pig_ci/profiler_engine/rails.rb', line 3

def initialize(profilers: nil, reports: nil)
  @profilers = profilers || [
    PigCI::Profiler::Memory.new,
    PigCI::Profiler::RequestTime.new,
    PigCI::Profiler::DatabaseRequest.new
  ]
  @reports = reports || [
    PigCI::Report::Memory.new,
    PigCI::Report::RequestTime.new,
    PigCI::Report::DatabaseRequest.new
  ]
  @request_captured = false
end

Instance Method Details

#request_key_from_payload!(payload) ⇒ Object


17
18
19
# File 'lib/pig_ci/profiler_engine/rails.rb', line 17

def request_key_from_payload!(payload)
  @request_key = "#{payload[:method]} #{payload[:controller]}##{payload[:action]}{format:#{payload[:format]}}"
end

#setup!Object


21
22
23
24
25
26
27
# File 'lib/pig_ci/profiler_engine/rails.rb', line 21

def setup!
  super do
    precompile_assets! if PigCI.during_setup_precompile_assets?
    eager_load_rails! if PigCI.during_setup_eager_load_application?
    make_blank_application_request! if PigCI.during_setup_make_blank_application_request?
  end
end