Method: NewRelic::Agent::TransactionSampler#initialize

Defined in:
lib/new_relic/agent/transaction_sampler.rb

#initializeTransactionSampler

Returns a new instance of TransactionSampler.


22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/new_relic/agent/transaction_sampler.rb', line 22

def initialize
  @sample_buffers = []
  @sample_buffers << NewRelic::Agent::Transaction::SlowestSampleBuffer.new
  @sample_buffers << NewRelic::Agent::Transaction::SyntheticsSampleBuffer.new

  # This lock is used to synchronize access to the @last_sample
  # and related variables. It can become necessary on JRuby or
  # any 'honest-to-god'-multithreaded system
  @samples_lock = Mutex.new

  Agent.config.register_callback(:'transaction_tracer.enabled') do |enabled|
    if enabled
      threshold = Agent.config[:'transaction_tracer.transaction_threshold']
      ::NewRelic::Agent.logger.debug("Transaction tracing threshold is #{threshold} seconds.")
    else
      ::NewRelic::Agent.logger.debug('Transaction traces will not be sent to the New Relic service.')
    end
  end

  Agent.config.register_callback(:'transaction_tracer.record_sql') do |config|
    if config == 'raw'
      ::NewRelic::Agent.logger.warn('Agent is configured to send raw SQL to the service')
    end
  end
end