Sha256: 68f774f0dc351463ffc7048713ce813f227b2e7802649c48effc58e6b17213f8

Contents?: true

Size: 1.24 KB

Versions: 9

Compression:

Stored size: 1.24 KB

Contents

# Copyright (c) 2021 Contrast Security, Inc. See https://www.contrastsecurity.com/enduser-terms-0317a for more details.
# frozen_string_literal: true

require 'contrast/components/base'
require 'contrast/components/heap_dump'

module Contrast
  module Components
    module HeapDump
      # A wrapper build around the Common Agent Configuration project to allow
      # for access of the values contained in its
      # parent_configuration_spec.yaml.
      # Specifically, this allows for querying the state of the Heap Dump
      # utility.
      module ClassMethods
        include Contrast::Components::ComponentBase

        def heap_dump_enabled?
          heap_dump_control[:enabled]
        end

        def heap_dump_control
          @_heap_dump_control ||= begin
            config = ::Contrast::CONFIG.root&.agent&.heap_dump
            {
                enabled: true?(config&.enable),
                path: File.absolute_path(config&.path),
                count: config&.count.to_i || 0,
                window: (config&.window_ms.to_f || 0) / 1000,
                delay: (config&.delay_ms.to_f || 0) / 1000,
                clean: true?(config&.clean)
            }
          end
        end
      end
      InstanceMethods = ClassMethods
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
contrast-agent-4.14.1 lib/contrast/components/heap_dump.rb
contrast-agent-4.14.0 lib/contrast/components/heap_dump.rb
contrast-agent-4.13.1 lib/contrast/components/heap_dump.rb
contrast-agent-4.13.0 lib/contrast/components/heap_dump.rb
contrast-agent-4.12.0 lib/contrast/components/heap_dump.rb
contrast-agent-4.11.0 lib/contrast/components/heap_dump.rb
contrast-agent-4.10.0 lib/contrast/components/heap_dump.rb
contrast-agent-4.9.1 lib/contrast/components/heap_dump.rb
contrast-agent-4.9.0 lib/contrast/components/heap_dump.rb