Class: AppProfiler::Parameters

Inherits:
Object
  • Object
show all
Defined in:
lib/app_profiler/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 Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(mode: :wall, interval: nil, ignore_gc: false, autoredirect: false, async: false, metadata: {}) ⇒ Parameters

Returns a new instance of Parameters.



13
14
15
16
17
18
19
20
# File 'lib/app_profiler/parameters.rb', line 13

def initialize(mode: :wall, interval: nil, ignore_gc: false, autoredirect: false, async: false, metadata: {})
  @mode = mode.to_sym
  @interval = [interval&.to_i || DEFAULT_INTERVALS.fetch(@mode.to_s), MIN_INTERVALS.fetch(@mode.to_s)].max
  @ignore_gc = !!ignore_gc
  @autoredirect = autoredirect
  @metadata = { context: AppProfiler.context }.merge()
  @async = async
end

Instance Attribute Details

#asyncObject (readonly)

Returns the value of attribute async.



11
12
13
# File 'lib/app_profiler/parameters.rb', line 11

def async
  @async
end

#autoredirectObject (readonly)

Returns the value of attribute autoredirect.



11
12
13
# File 'lib/app_profiler/parameters.rb', line 11

def autoredirect
  @autoredirect
end

Instance Method Details

#to_hObject



26
27
28
29
30
31
32
33
# File 'lib/app_profiler/parameters.rb', line 26

def to_h
  {
    mode: @mode,
    interval: @interval,
    ignore_gc: @ignore_gc,
    metadata: @metadata,
  }
end

#valid?Boolean

Returns:

  • (Boolean)


22
23
24
# File 'lib/app_profiler/parameters.rb', line 22

def valid?
  true
end