Class: TingYun::Agent::Collector::StatsEngine

Inherits:
Object
  • Object
show all
Includes:
MetricStats
Defined in:
lib/ting_yun/agent/collector/stats_engine.rb,
lib/ting_yun/agent/collector/stats_engine/metric_stats.rb

Overview

This class handles all the statistics gathering for the agent

Defined Under Namespace

Modules: MetricStats

Constant Summary

Constants included from MetricStats

MetricStats::SCOPE_PLACEHOLDER

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from MetricStats

#coerce_to_metric_spec_array, #harvest!, #harvest_base_quantile_hash!, #merge!, #merge_transaction_metrics!, #record_scoped_and_unscoped_metrics, #record_scoped_metrics, #record_unscoped_metrics, #reset!, #reset_stats, #tl_record_scoped_and_unscoped_metrics, #tl_record_scoped_metrics, #tl_record_unscoped_metrics, #to_h

Constructor Details

#initializeStatsEngine

Returns a new instance of StatsEngine.



17
18
19
20
21
# File 'lib/ting_yun/agent/collector/stats_engine.rb', line 17

def initialize
  @stats_lock = Mutex.new
  @stats_hash = StatsHash.new
  @base_quantile_hash = BaseQuantileHash.new
end

Instance Attribute Details

#base_quantile_hashObject (readonly)

Returns the value of attribute base_quantile_hash.



15
16
17
# File 'lib/ting_yun/agent/collector/stats_engine.rb', line 15

def base_quantile_hash
  @base_quantile_hash
end

Instance Method Details

#record_base_quantile(hash) ⇒ Object



29
30
31
32
33
# File 'lib/ting_yun/agent/collector/stats_engine.rb', line 29

def record_base_quantile(hash)
  with_stats_lock do
    @base_quantile_hash.merge!(hash)
  end
end

#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/ting_yun/agent/collector/stats_engine.rb', line 25

def with_stats_lock
  @stats_lock.synchronize { yield }
end