Method: Datadog::Sampling::TokenBucket#allow?
- Defined in:
- lib/ddtrace/sampling/rate_limiter.rb
#allow?(size) ⇒ Boolean
Checks if a message of provided size conforms with the current bucket limit.
If it does, return true and remove size tokens from the bucket. If it does not, return false without affecting the tokens form the bucket.
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/ddtrace/sampling/rate_limiter.rb', line 53 def allow?(size) return false if @rate.zero? return true if @rate < 0 increment_total_count return false if @tokens < size increment_conforming_count @tokens -= size true end |