# Copyright (c) 2022 Contrast Security, Inc. See https://www.contrastsecurity.com/enduser-terms-0317a for more details. # frozen_string_literal: true module Contrast module Config # Common Configuration settings. Those in this section pertain to the # Heap Dump collection functionality of the Agent. class HeapDumpConfiguration < BaseConfiguration DEFAULT_PATH = 'contrast_heap_dumps' # saved DEFAULT_MS = 10_000 DEFAULT_COUNT = 5 attr_writer :enable, :path, :delay_ms, :window_ms, :count, :clean def initialize hsh = {} @enable = traverse_config(hsh, :enable) @path = traverse_config(hsh, :path) @delay_ms = traverse_config(hsh, :delay_ms) @window_ms = traverse_config(hsh, :window_ms) @count = traverse_config(hsh, :count) @clean = traverse_config(hsh, :clean) end # @return [Boolean, Contrast::Utils::ObjectShare::FALSE] should dumps be taken def enable @enable.nil? ? Contrast::Utils::ObjectShare::FALSE : @enable end # @return [String, DEFAULT_PATH] dir to which dumps should be def path @path ||= DEFAULT_PATH end # @return [Integer, DEFAULT_MS] time, in ms, after initialization def delay_ms @delay_ms ||= DEFAULT_MS end # @return [Integer, DEFAULT_MS] ms between each dump def window_ms @window_ms ||= DEFAULT_MS end # @return [Integer, DEFAULT_MS] number of dumps to take def count @count ||= DEFAULT_COUNT end # @return [Boolean, Contrast::Utils::ObjectShare::FALSE] remove temporary objects or not def clean @clean.nil? ? Contrast::Utils::ObjectShare::FALSE : @clean end end end end