# 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 include Contrast::Config::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 = {} return unless hsh @enable = hsh[:enable] @path = hsh[:path] @delay_ms = hsh[:delay_ms] @window_ms = hsh[:window_ms] @count = hsh[:count] @clean = 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