Class: AppProfiler::RequestParameters
- Inherits:
-
Object
- Object
- AppProfiler::RequestParameters
- Defined in:
- lib/app_profiler/request_parameters.rb
Constant Summary collapse
- DEFAULT_INTERVALS =
{ "cpu" => 1000, "wall" => 1000, "object" => 2000 }.freeze
- MIN_INTERVALS =
{ "cpu" => 200, "wall" => 200, "object" => 400 }.freeze
- MODES =
DEFAULT_INTERVALS.keys.freeze
Instance Method Summary collapse
- #autoredirect ⇒ Object
-
#initialize(request) ⇒ RequestParameters
constructor
A new instance of RequestParameters.
- #to_h ⇒ Object
- #valid? ⇒ Boolean
Constructor Details
#initialize(request) ⇒ RequestParameters
Returns a new instance of RequestParameters.
11 12 13 |
# File 'lib/app_profiler/request_parameters.rb', line 11 def initialize(request) @request = request end |
Instance Method Details
#autoredirect ⇒ Object
15 16 17 |
# File 'lib/app_profiler/request_parameters.rb', line 15 def autoredirect query_param("autoredirect") || profile_header_param("autoredirect") end |
#to_h ⇒ Object
36 37 38 39 40 41 42 43 44 45 |
# File 'lib/app_profiler/request_parameters.rb', line 36 def to_h { mode: mode.to_sym, interval: interval.to_i, metadata: { id: request_id, context: context, }, } end |
#valid? ⇒ Boolean
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/app_profiler/request_parameters.rb', line 19 def valid? if mode.blank? return false end unless MODES.include?(mode) AppProfiler.logger.info("[Profiler] unsupported profiling mode=#{mode}") return false end if interval.to_i < MIN_INTERVALS[mode] return false end true end |