Class: Datadog::AppSec::SampleRate
- Inherits:
-
Object
- Object
- Datadog::AppSec::SampleRate
- Defined in:
- lib/datadog/appsec/sample_rate.rb
Overview
SampleRate basic sample rate
Instance Attribute Summary collapse
-
#rate ⇒ Object
readonly
Returns the value of attribute rate.
Instance Method Summary collapse
-
#initialize(rate) ⇒ SampleRate
constructor
A new instance of SampleRate.
- #sample? ⇒ Boolean
Constructor Details
#initialize(rate) ⇒ SampleRate
Returns a new instance of SampleRate.
9 10 11 |
# File 'lib/datadog/appsec/sample_rate.rb', line 9 def initialize(rate) @rate = rate end |
Instance Attribute Details
#rate ⇒ Object (readonly)
Returns the value of attribute rate.
7 8 9 |
# File 'lib/datadog/appsec/sample_rate.rb', line 7 def rate @rate end |
Instance Method Details
#sample? ⇒ Boolean
13 14 15 16 17 18 |
# File 'lib/datadog/appsec/sample_rate.rb', line 13 def sample? return false if rate <= 0 return true if rate >= 1 Kernel.rand < rate end |