Class: SentrySmartSampler::ThrottlingPerErrorRegistry::Registration

Inherits:
Object
  • Object
show all
Defined in:
lib/sentry_smart_sampler/throttling_per_error_registry.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(throttable:, threshold:, time_unit:) ⇒ Registration

Returns a new instance of Registration.



32
33
34
35
36
# File 'lib/sentry_smart_sampler/throttling_per_error_registry.rb', line 32

def initialize(throttable:, threshold:, time_unit:)
  @throttable = throttable
  @threshold = threshold
  @time_unit = time_unit
end

Instance Attribute Details

#thresholdObject (readonly)

Returns the value of attribute threshold.



30
31
32
# File 'lib/sentry_smart_sampler/throttling_per_error_registry.rb', line 30

def threshold
  @threshold
end

#throttableObject (readonly)

Returns the value of attribute throttable.



30
31
32
# File 'lib/sentry_smart_sampler/throttling_per_error_registry.rb', line 30

def throttable
  @throttable
end

#time_unitObject (readonly)

Returns the value of attribute time_unit.



30
31
32
# File 'lib/sentry_smart_sampler/throttling_per_error_registry.rb', line 30

def time_unit
  @time_unit
end

Instance Method Details

#matches?(matchable_error) ⇒ Boolean

Returns:

  • (Boolean)


38
39
40
41
42
43
44
# File 'lib/sentry_smart_sampler/throttling_per_error_registry.rb', line 38

def matches?(matchable_error)
  if throttable.is_a?(Regexp) || throttable.respond_to?(:to_str)
    matchable_error.message.scan(throttable).any?
  else
    matchable_error.is_a?(throttable)
  end
end