Module: Couchbase::Operations::Stats

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

Instance Method Summary collapse

Instance Method Details

#stats(statname = nil) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/couchbase/operations/stats.rb', line 4

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