Class: SentrySmartSampler::SampleRatePerErrorRegistry::Registration

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(samplable:, sample_rate:) ⇒ Registration

Returns a new instance of Registration.



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

def initialize(samplable:, sample_rate:)
  @samplable = samplable
  @sample_rate = sample_rate
end

Instance Attribute Details

#samplableObject (readonly)

Returns the value of attribute samplable.



28
29
30
# File 'lib/sentry_smart_sampler/sample_rate_per_error_registry.rb', line 28

def samplable
  @samplable
end

#sample_rateObject (readonly)

Returns the value of attribute sample_rate.



28
29
30
# File 'lib/sentry_smart_sampler/sample_rate_per_error_registry.rb', line 28

def sample_rate
  @sample_rate
end

Instance Method Details

#matches?(matchable_error) ⇒ Boolean

Returns:

  • (Boolean)


35
36
37
38
39
40
41
# File 'lib/sentry_smart_sampler/sample_rate_per_error_registry.rb', line 35

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