Class: Metrix::Mongodb

Inherits:
Base
  • Object
show all
Includes:
JsonMetric
Defined in:
lib/metrix/mongodb.rb

Constant Summary collapse

DATABASE_RECORD_SET =
/^recordStats\.(.*?)\.(.*)/
DATABASE_LOCK =
/^locks/

Instance Attribute Summary

Attributes inherited from Base

#attributes, #time

Instance Method Summary collapse

Methods included from JsonMetric

#attributes, #extract

Methods inherited from Base

#cast_int, ignore, #ignore_metric?, ignore_metrics, inherited, #initialize, known_metrics, prefix, #prefix, set_known_metrics, set_prefix, subclasses, #tagged_metrics, #tags, #unfiltered_metrics

Constructor Details

This class inherits a constructor from Metrix::Base

Instance Method Details

#metricsObject



36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# File 'lib/metrix/mongodb.rb', line 36

def metrics
  unfiltered_metrics.map do |k, v|
    next unless self.class.known_metrics.include?(k)
    if k.match(DATABASE_RECORD_SET)
      next if %w(accessesNotInMemory pageFaultExceptionsThrown).include?($2)
      database = $1
      Metric.new("#{prefix}.#{$2}", v, time, database: database)
    elsif k.match(DATABASE_LOCK)
      chunks = k.split(".")
      offset = 0
      offset = 1 if chunks.at(1) == "" # for "." database
      database = chunks.at(1 + offset)
      metric = chunks[(2 + offset)..-1].join(".")
      database = "." if database == ""
      Metric.new("#{prefix}.recordStats.#{metric}", v, time, database: database)
    else
      Metric.new("#{prefix}.#{k}", v, time)
    end
  end.compact
end