class Sqreen::Ecosystem::Tracing::Sampler::MaxCallsPrimitive

Public Class Methods

new(max_calls) click to toggle source
# File lib/sqreen/ecosystem/tracing/sampler.rb, line 138
def initialize(max_calls)
  @max_calls = max_calls
  @disabled = false # to avoid lock
  @mutex = Mutex.new
  @num_calls = 0
end

Public Instance Methods

triggers?() click to toggle source
# File lib/sqreen/ecosystem/tracing/sampler.rb, line 145
def triggers?
  return false if @disabled
  num_calls = @mutex.synchronize do
    @num_calls += 1
  end

  num_calls <= @max_calls
end