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, "retained" => 0 }.freeze
MIN_INTERVALS =
{ "cpu" => 200, "wall" => 200, "object" => 400, "retained" => 0 }.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

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

Returns a new instance of Parameters.



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

def initialize(mode: :wall, interval: nil, ignore_gc: false, autoredirect: false,
  async: false, backend: nil, 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
  @backend = backend || AppProfiler::Backend::StackprofBackend.name
  @metadata = { context: AppProfiler.context }.merge()
  @async = async
end

Instance Attribute Details

#asyncObject (readonly)

Returns the value of attribute async.



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

def async
  @async
end

#autoredirectObject (readonly)

Returns the value of attribute autoredirect.



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

def autoredirect
  @autoredirect
end

#backendObject (readonly)

Returns the value of attribute backend.



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

def backend
  @backend
end

#modeObject (readonly)

Returns the value of attribute mode.



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

def mode
  @mode
end

Instance Method Details

#to_hObject



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

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

#valid?Boolean

Returns:

  • (Boolean)


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

def valid?
  true
end