Class: HeapScope::Config
- Inherits:
-
Object
- Object
- HeapScope::Config
- Defined in:
- lib/heapscope/config.rb
Constant Summary collapse
- MODES =
%i[lightweight standard deep production_safe development].freeze
- SNAPSHOT_MODES =
%i[lightweight standard deep].freeze
Instance Attribute Summary collapse
-
#apply_noise_defaults ⇒ Object
Returns the value of attribute apply_noise_defaults.
-
#debug ⇒ Object
Returns the value of attribute debug.
-
#detect_closures ⇒ Object
Returns the value of attribute detect_closures.
-
#detect_fibers ⇒ Object
Returns the value of attribute detect_fibers.
-
#detect_globals ⇒ Object
Returns the value of attribute detect_globals.
-
#detect_thread_locals ⇒ Object
Returns the value of attribute detect_thread_locals.
-
#force_gc_default ⇒ Object
Returns the value of attribute force_gc_default.
-
#ignore_patterns ⇒ Object
Returns the value of attribute ignore_patterns.
-
#ignored_classes ⇒ Object
Returns the value of attribute ignored_classes.
-
#include_runtime_objects ⇒ Object
Returns the value of attribute include_runtime_objects.
-
#inspect_values ⇒ Object
Returns the value of attribute inspect_values.
-
#logger ⇒ Object
Returns the value of attribute logger.
-
#max_edges ⇒ Object
Returns the value of attribute max_edges.
-
#max_graph_depth ⇒ Object
Returns the value of attribute max_graph_depth.
-
#max_objects ⇒ Object
Returns the value of attribute max_objects.
-
#max_pause_ms ⇒ Object
Returns the value of attribute max_pause_ms.
-
#min_retention_cycles ⇒ Object
Returns the value of attribute min_retention_cycles.
-
#mode ⇒ Object
Returns the value of attribute mode.
-
#object_sample_rate ⇒ Object
Returns the value of attribute object_sample_rate.
-
#quiet ⇒ Object
Returns the value of attribute quiet.
-
#rails ⇒ Object
Returns the value of attribute rails.
-
#redactor ⇒ Object
Returns the value of attribute redactor.
-
#track_allocations ⇒ Object
Returns the value of attribute track_allocations.
-
#verbose ⇒ Object
Returns the value of attribute verbose.
-
#warmup_done ⇒ Object
Returns the value of attribute warmup_done.
Instance Method Summary collapse
- #development? ⇒ Boolean
- #effective_snapshot_mode(requested = nil) ⇒ Object
- #ignore_class?(name) ⇒ Boolean
-
#initialize ⇒ Config
constructor
A new instance of Config.
- #log(level, message) ⇒ Object
- #production_safe? ⇒ Boolean
- #redact(object) ⇒ Object
- #snapshot_mode_for_config ⇒ Object
Constructor Details
#initialize ⇒ Config
Returns a new instance of Config.
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/heapscope/config.rb', line 34 def initialize @mode = :standard @track_allocations = false @max_graph_depth = 6 @max_objects = 100_000 @max_edges = 500_000 @max_pause_ms = nil @object_sample_rate = 1.0 @force_gc_default = false @include_runtime_objects = false @ignore_patterns = [/^HeapScope::/] @ignored_classes = [] @inspect_values = false @verbose = false @debug = false @rails = false @redactor = nil @logger = nil @warmup_done = false @min_retention_cycles = 3 @detect_globals = true @detect_closures = false @detect_fibers = true @detect_thread_locals = true @apply_noise_defaults = true @quiet = false end |
Instance Attribute Details
#apply_noise_defaults ⇒ Object
Returns the value of attribute apply_noise_defaults.
8 9 10 |
# File 'lib/heapscope/config.rb', line 8 def apply_noise_defaults @apply_noise_defaults end |
#debug ⇒ Object
Returns the value of attribute debug.
8 9 10 |
# File 'lib/heapscope/config.rb', line 8 def debug @debug end |
#detect_closures ⇒ Object
Returns the value of attribute detect_closures.
8 9 10 |
# File 'lib/heapscope/config.rb', line 8 def detect_closures @detect_closures end |
#detect_fibers ⇒ Object
Returns the value of attribute detect_fibers.
8 9 10 |
# File 'lib/heapscope/config.rb', line 8 def detect_fibers @detect_fibers end |
#detect_globals ⇒ Object
Returns the value of attribute detect_globals.
8 9 10 |
# File 'lib/heapscope/config.rb', line 8 def detect_globals @detect_globals end |
#detect_thread_locals ⇒ Object
Returns the value of attribute detect_thread_locals.
8 9 10 |
# File 'lib/heapscope/config.rb', line 8 def detect_thread_locals @detect_thread_locals end |
#force_gc_default ⇒ Object
Returns the value of attribute force_gc_default.
8 9 10 |
# File 'lib/heapscope/config.rb', line 8 def force_gc_default @force_gc_default end |
#ignore_patterns ⇒ Object
Returns the value of attribute ignore_patterns.
8 9 10 |
# File 'lib/heapscope/config.rb', line 8 def ignore_patterns @ignore_patterns end |
#ignored_classes ⇒ Object
Returns the value of attribute ignored_classes.
8 9 10 |
# File 'lib/heapscope/config.rb', line 8 def ignored_classes @ignored_classes end |
#include_runtime_objects ⇒ Object
Returns the value of attribute include_runtime_objects.
8 9 10 |
# File 'lib/heapscope/config.rb', line 8 def include_runtime_objects @include_runtime_objects end |
#inspect_values ⇒ Object
Returns the value of attribute inspect_values.
8 9 10 |
# File 'lib/heapscope/config.rb', line 8 def inspect_values @inspect_values end |
#logger ⇒ Object
Returns the value of attribute logger.
8 9 10 |
# File 'lib/heapscope/config.rb', line 8 def logger @logger end |
#max_edges ⇒ Object
Returns the value of attribute max_edges.
8 9 10 |
# File 'lib/heapscope/config.rb', line 8 def max_edges @max_edges end |
#max_graph_depth ⇒ Object
Returns the value of attribute max_graph_depth.
8 9 10 |
# File 'lib/heapscope/config.rb', line 8 def max_graph_depth @max_graph_depth end |
#max_objects ⇒ Object
Returns the value of attribute max_objects.
8 9 10 |
# File 'lib/heapscope/config.rb', line 8 def max_objects @max_objects end |
#max_pause_ms ⇒ Object
Returns the value of attribute max_pause_ms.
8 9 10 |
# File 'lib/heapscope/config.rb', line 8 def max_pause_ms @max_pause_ms end |
#min_retention_cycles ⇒ Object
Returns the value of attribute min_retention_cycles.
8 9 10 |
# File 'lib/heapscope/config.rb', line 8 def min_retention_cycles @min_retention_cycles end |
#mode ⇒ Object
Returns the value of attribute mode.
8 9 10 |
# File 'lib/heapscope/config.rb', line 8 def mode @mode end |
#object_sample_rate ⇒ Object
Returns the value of attribute object_sample_rate.
8 9 10 |
# File 'lib/heapscope/config.rb', line 8 def object_sample_rate @object_sample_rate end |
#quiet ⇒ Object
Returns the value of attribute quiet.
8 9 10 |
# File 'lib/heapscope/config.rb', line 8 def quiet @quiet end |
#rails ⇒ Object
Returns the value of attribute rails.
8 9 10 |
# File 'lib/heapscope/config.rb', line 8 def rails @rails end |
#redactor ⇒ Object
Returns the value of attribute redactor.
8 9 10 |
# File 'lib/heapscope/config.rb', line 8 def redactor @redactor end |
#track_allocations ⇒ Object
Returns the value of attribute track_allocations.
8 9 10 |
# File 'lib/heapscope/config.rb', line 8 def track_allocations @track_allocations end |
#verbose ⇒ Object
Returns the value of attribute verbose.
8 9 10 |
# File 'lib/heapscope/config.rb', line 8 def verbose @verbose end |
#warmup_done ⇒ Object
Returns the value of attribute warmup_done.
8 9 10 |
# File 'lib/heapscope/config.rb', line 8 def warmup_done @warmup_done end |
Instance Method Details
#development? ⇒ Boolean
66 67 68 |
# File 'lib/heapscope/config.rb', line 66 def development? mode == :development end |
#effective_snapshot_mode(requested = nil) ⇒ Object
70 71 72 73 74 75 |
# File 'lib/heapscope/config.rb', line 70 def effective_snapshot_mode(requested = nil) requested ||= snapshot_mode_for_config return :lightweight if production_safe? && requested == :deep requested end |
#ignore_class?(name) ⇒ Boolean
85 86 87 88 89 |
# File 'lib/heapscope/config.rb', line 85 def ignore_class?(name) return true if ignored_classes.map(&:to_s).include?(name.to_s) ignore_patterns.any? { |pattern| name.to_s.match?(pattern) } end |
#log(level, message) ⇒ Object
98 99 100 101 102 103 |
# File 'lib/heapscope/config.rb', line 98 def log(level, ) return unless logger || verbose || debug return if level == :debug && !debug (logger || $stderr).puts("[HeapScope] #{}") end |
#production_safe? ⇒ Boolean
62 63 64 |
# File 'lib/heapscope/config.rb', line 62 def production_safe? mode == :production_safe end |
#redact(object) ⇒ Object
91 92 93 94 95 96 |
# File 'lib/heapscope/config.rb', line 91 def redact(object) return nil unless inspect_values return redactor.call(object) if redactor :"[redacted]" end |
#snapshot_mode_for_config ⇒ Object
77 78 79 80 81 82 83 |
# File 'lib/heapscope/config.rb', line 77 def snapshot_mode_for_config case mode when :lightweight, :production_safe then :lightweight when :deep, :development then :deep else :standard end end |