Sha256: 82d5607ee8d2c78fee1ca8c4d968a993db5bbfd5972bab7547bd05696ab14631

Contents?: true

Size: 956 Bytes

Versions: 7

Compression:

Stored size: 956 Bytes

Contents

# encoding: utf-8

require 'ting_yun/agent/collector/stats_engine/stats_hash'
require 'ting_yun/agent/collector/stats_engine/metric_stats'
require 'ting_yun/agent/collector/stats_engine/base_quantile_hash'

module TingYun
  module Agent
    module Collector
      # This class handles all the statistics gathering for the agent
      class StatsEngine

        include MetricStats

        attr_reader :base_quantile_hash

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

        # All access to the @stats_hash ivar should be funnelled through this
        # method to ensure thread-safety.
        def with_stats_lock
          @stats_lock.synchronize { yield }
        end

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

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
tingyun_rpm-3.2.0 lib/ting_yun/agent/collector/stats_engine.rb
tingyun_rpm-1.6.1 lib/ting_yun/agent/collector/stats_engine.rb
tingyun_rpm-1.5.0 lib/ting_yun/agent/collector/stats_engine.rb
tingyun_rpm-1.4.2 lib/ting_yun/agent/collector/stats_engine.rb
tingyun_rpm-1.4.1 lib/ting_yun/agent/collector/stats_engine.rb
tingyun_rpm-1.3.1 lib/ting_yun/agent/collector/stats_engine.rb
tingyun_rpm-1.3.0 lib/ting_yun/agent/collector/stats_engine.rb