Class: NewRelic::Agent::StatsEngine

Inherits:
Object
  • Object
show all
Includes:
MetricStats, Samplers, Transactions
Defined in:
lib/new_relic/agent/stats_engine.rb,
lib/new_relic/agent/stats_engine/samplers.rb,
lib/new_relic/agent/stats_engine/gc_profiler.rb,
lib/new_relic/agent/stats_engine/metric_stats.rb,
lib/new_relic/agent/stats_engine/transactions.rb

Overview

This class handles all the statistics gathering for the agent

Defined Under Namespace

Modules: GCProfiler, MetricStats, Samplers, Shim, Transactions Classes: ScopeStackElement

Constant Summary

Constants included from Samplers

Samplers::POLL_PERIOD

Instance Attribute Summary

Attributes included from Transactions

#transaction_sampler

Instance Method Summary collapse

Methods included from Transactions

#end_transaction, #peek_scope, #pop_scope, #push_scope, #remove_transaction_sampler, #rename_scope_segment, #sampler_enabled?, #scope_name, #scope_name=, #start_transaction

Methods included from Samplers

#add_harvest_sampler, #add_sampler, #start_sampler_thread

Methods included from MetricStats

#apply_rules_to_metric_data, #clear_stats, #coerce_to_metric_spec_array, #default_scope, #get_stats, #get_stats_no_scope, #harvest_timeslice_data, #lookup_stats, #merge!, #metrics, #record_metric, #record_supportability_metrics, #record_supportability_metrics_count, #record_supportability_metrics_timed, #reset_stats

Constructor Details

#initializeStatsEngine

Returns a new instance of StatsEngine.



15
16
17
18
19
20
21
# File 'lib/new_relic/agent/stats_engine.rb', line 15

def initialize
  # Makes the unit tests happy
  Thread::current[:newrelic_scope_stack] = nil
  @stats_lock = Mutex.new
  @stats_hash = StatsHash.new
  start_sampler_thread
end

Instance Method Details

#with_stats_lockObject

All access to the @stats_hash ivar should be funnelled through this method to ensure thread-safety.



25
26
27
# File 'lib/new_relic/agent/stats_engine.rb', line 25

def with_stats_lock
  @stats_lock.synchronize { yield }
end