Class: SentrySmartSampler::Sampler
- Inherits:
-
Object
- Object
- SentrySmartSampler::Sampler
- Defined in:
- lib/sentry_smart_sampler/sampler.rb
Instance Method Summary collapse
- #call(event, hint) ⇒ Object
-
#initialize(registry, random_generator: Random, configuration: SentrySmartSampler.configuration) ⇒ Sampler
constructor
A new instance of Sampler.
Constructor Details
#initialize(registry, random_generator: Random, configuration: SentrySmartSampler.configuration) ⇒ Sampler
10 11 12 13 14 15 16 |
# File 'lib/sentry_smart_sampler/sampler.rb', line 10 def initialize(registry, random_generator: Random, configuration: SentrySmartSampler.configuration) @registry = registry @random_generator = random_generator @cache_storage = configuration.cache_storage @after_throttling_threshold_reached = configuration.after_throttling_threshold_reached @throttling_threshold_reached_definition = configuration.throttling_threshold_reached_definition end |
Instance Method Details
#call(event, hint) ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/sentry_smart_sampler/sampler.rb', line 18 def call(event, hint) error = hint[:exception] throttling_registration = registry.throttling_registration_for(error) if apply_throttling?(throttling_registration) rate_limit = initialize_rate_limit(throttling_registration, error) already_throttled = rate_limit.throttled? rate_limit.increase after_throttling_threshold_reached.call(event, hint) if throttling_threshold_reached_definition.reached?( rate_limit, throttling_registration, error ) return if already_throttled end sample(event, error) end |