Sha256: ffde0ba0707f6898c311e3ab3db24598486020ac830e3b9285202b791921ffc3

Contents?: true

Size: 1.78 KB

Versions: 5

Compression:

Stored size: 1.78 KB

Contents

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

require 'contrast/utils/object_share'

module Contrast
  module Agent
    module Reporting
      module Settings
        # Sampling controls for the Assess Features provided by TeamServer
        class Sampling
          # @return [Integer] The number of baseline requests to take before switching to sampling for the window.
          attr_reader :baseline
          # @return [Boolean] If the sampling feature should be used or not.
          attr_reader :enabled
          # @return [Integer] The number of requests to skip before observing during the sampling window after the
          #   baseline.
          attr_reader :request_frequency
          # @return [Integer] The number of responses to skip before observing during the sampling window after the
          #  baseline.
          attr_reader :response_frequency
          # @return [Integer] The length of time for which the sample period is valid, in ms.
          attr_reader :window_ms

          def initialize hsh
            @baseline = hsh[:baseline]
            # NG endpoints vs non-ng
            @enabled = hsh[:enabled] || hsh[:enable]
            @request_frequency = hsh[:frequency] || hsh[:request_frequency]
            @response_frequency = hsh[:responseFrequency] || hsh[:response_frequency]
            @window_ms = hsh[:window] || hsh[:window_ms]
          end

          def to_controlled_hash
            {
                baseline: baseline,
                enabled: enabled,
                frequency: request_frequency,
                responseFrequency: response_frequency,
                window: window_ms
            }
          end
        end
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
contrast-agent-7.6.1 lib/contrast/agent/reporting/settings/sampling.rb
contrast-agent-7.6.0 lib/contrast/agent/reporting/settings/sampling.rb
contrast-agent-7.5.0 lib/contrast/agent/reporting/settings/sampling.rb
contrast-agent-7.4.1 lib/contrast/agent/reporting/settings/sampling.rb
contrast-agent-7.4.0 lib/contrast/agent/reporting/settings/sampling.rb