Class: SentrySmartSampler::ThrottlingPerErrorRegistry
- Inherits:
-
Object
- Object
- SentrySmartSampler::ThrottlingPerErrorRegistry
- Defined in:
- lib/sentry_smart_sampler/throttling_per_error_registry.rb
Defined Under Namespace
Classes: Registration
Instance Method Summary collapse
- #declare(throttable, time_unit:, threshold:) ⇒ Object
-
#initialize(default_throttling_errors_number_threshold, default_throttling_time_unit) ⇒ ThrottlingPerErrorRegistry
constructor
A new instance of ThrottlingPerErrorRegistry.
- #throttling_registration_for(error) ⇒ Object
Constructor Details
#initialize(default_throttling_errors_number_threshold, default_throttling_time_unit) ⇒ ThrottlingPerErrorRegistry
Returns a new instance of ThrottlingPerErrorRegistry.
8 9 10 11 12 |
# File 'lib/sentry_smart_sampler/throttling_per_error_registry.rb', line 8 def initialize(default_throttling_errors_number_threshold, default_throttling_time_unit) @default_throttling_errors_number_threshold = default_throttling_errors_number_threshold @default_throttling_time_unit = default_throttling_time_unit @registry = [] end |
Instance Method Details
#declare(throttable, time_unit:, threshold:) ⇒ Object
14 15 16 |
# File 'lib/sentry_smart_sampler/throttling_per_error_registry.rb', line 14 def declare(throttable, time_unit:, threshold:) registry << Registration.new(throttable: throttable, time_unit: time_unit, threshold: threshold) end |
#throttling_registration_for(error) ⇒ Object
18 19 20 |
# File 'lib/sentry_smart_sampler/throttling_per_error_registry.rb', line 18 def throttling_registration_for(error) registry.find(-> { default_registration }) { |registration| registration.matches?(error) } end |