Module: Contrast::Components::Sampling::ClassMethods

Includes:
ComponentBase, Constants
Included in:
InstanceMethods, Interface
Defined in:
lib/contrast/components/sampling.rb

Overview

:nodoc:

Constant Summary

Constants included from Constants

Contrast::Components::Sampling::Constants::DEFAULT_SAMPLING_BASELINE, Contrast::Components::Sampling::Constants::DEFAULT_SAMPLING_ENABLED, Contrast::Components::Sampling::Constants::DEFAULT_SAMPLING_REQUEST_FREQUENCY, Contrast::Components::Sampling::Constants::DEFAULT_SAMPLING_RESPONSE_FREQUENCY, Contrast::Components::Sampling::Constants::DEFAULT_SAMPLING_WINDOW_MS

Constants included from ComponentBase

ComponentBase::ENABLE

Constants included from Contrast::Config::Diagnostics::Tools

Contrast::Config::Diagnostics::Tools::CHECK

Constants included from Contrast::Config::Diagnostics::SingletonTools

Contrast::Config::Diagnostics::SingletonTools::API_CREDENTIALS, Contrast::Config::Diagnostics::SingletonTools::CONTRAST_MARK

Instance Method Summary collapse

Methods included from ComponentBase

#canon_name, #config_values, #false?, #file_exists?, #stringify_array, #to_effective_config, #true?, #valid_cert?

Methods included from Contrast::Config::Diagnostics::Tools

#add_effective_config_values, #add_single_effective_value

Methods included from Contrast::Config::Diagnostics::SingletonTools

#flatten_settings, #to_config_values, #update_config, #value_to_s

Instance Method Details

#reset_sampling_controlObject

Used to reset sampling when settings from TeamServer change



41
42
43
# File 'lib/contrast/components/sampling.rb', line 41

def reset_sampling_control
  @_sampling_control = nil
end

#sampling_controlObject



26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/contrast/components/sampling.rb', line 26

def sampling_control
  @_sampling_control ||= begin
    config_settings = ::Contrast::CONFIG.assess&.sampling
    settings = ::Contrast::SETTINGS&.assess_state&.sampling_settings
    {
        enabled: enabled?(config_settings&.enable, settings&.enabled),
        baseline: check_baseline(config_settings, settings),
        request_frequency: check_request_frequency(config_settings, settings),
        response_frequency: check_response_frequency(config_settings, settings),
        window: check_window(config_settings, settings)
    }
  end
end

#sampling_enabled?Boolean

Returns:

  • (Boolean)


22
23
24
# File 'lib/contrast/components/sampling.rb', line 22

def sampling_enabled?
  sampling_control[:enabled]
end