Module: Couchbase::Operations::Stats

Defined in:
lib/couchbase/operations/stats.rb

Instance Method Summary collapse

Instance Method Details

#stats(statname = nil) ⇒ Object



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/couchbase/operations/stats.rb', line 21

def stats(statname = nil)
  sync_block_error if !async? && block_given?
  stats = if statname.nil?
            client.getStats
          else
            client.getStats(statname)
          end

  stats = stats.to_hash

  {}.tap do |hash|
    stats.each_pair do |node, values|
      node_value = node.to_s
      values.each_pair do |stat, value|
        hash[stat] ||= {}
        hash[stat][node_value] = value
      end
    end
  end
end