Class: Maestro::Metrics::Real
- Inherits:
-
Object
- Object
- Maestro::Metrics::Real
- Includes:
- Mongo, Singleton
- Defined in:
- lib/maestro_metrics.rb
Instance Method Summary collapse
- #aggregate(collection, pipeline = nil) ⇒ Object
- #collection_names ⇒ Object
- #count(metric, value, sample_rate = 1) ⇒ Object
- #decrement(metric, sample_rate = 1) ⇒ Object
- #find(collection, selector = {}, opts = {}) ⇒ Object
- #increment(metric, sample_rate = 1) ⇒ Object
-
#initialize ⇒ Real
constructor
A new instance of Real.
- #log(collection, metrics) ⇒ Object
- #time(metric, sample_rate = 1, &block) ⇒ Object
- #timing(metric, value, sample_rate = 1) ⇒ Object
Constructor Details
#initialize ⇒ Real
Returns a new instance of Real.
106 107 108 109 110 111 |
# File 'lib/maestro_metrics.rb', line 106 def initialize @mongo_host = Metrics.config[:mongo_host] || 'localhost' @mongo_port = Metrics.config[:mongo_port] || 27017 @statsd_host = Metrics.config[:statsd_host] || 'localhost' @statsd_port = Metrics.config[:statsd_port] || 8125 end |
Instance Method Details
#aggregate(collection, pipeline = nil) ⇒ Object
137 138 139 |
# File 'lib/maestro_metrics.rb', line 137 def aggregate(collection, pipeline=nil) mongo_collection(collection).aggregate(pipeline) end |
#collection_names ⇒ Object
145 146 147 |
# File 'lib/maestro_metrics.rb', line 145 def collection_names mongo_db.collection_names end |
#count(metric, value, sample_rate = 1) ⇒ Object
113 114 115 |
# File 'lib/maestro_metrics.rb', line 113 def count(metric, value, sample_rate=1) statsd.count(metric, value, sample_rate) end |
#decrement(metric, sample_rate = 1) ⇒ Object
125 126 127 |
# File 'lib/maestro_metrics.rb', line 125 def decrement(metric, sample_rate=1) statsd.decrement(metric, sample_rate) end |
#find(collection, selector = {}, opts = {}) ⇒ Object
141 142 143 |
# File 'lib/maestro_metrics.rb', line 141 def find(collection, selector={}, opts={}) mongo_collection(collection).find(selector, opts) end |
#increment(metric, sample_rate = 1) ⇒ Object
121 122 123 |
# File 'lib/maestro_metrics.rb', line 121 def increment(metric, sample_rate=1) statsd.increment(metric, sample_rate) end |
#log(collection, metrics) ⇒ Object
133 134 135 |
# File 'lib/maestro_metrics.rb', line 133 def log(collection, metrics) mongo_collection(collection).save(metrics) end |
#time(metric, sample_rate = 1, &block) ⇒ Object
129 130 131 |
# File 'lib/maestro_metrics.rb', line 129 def time(metric, sample_rate=1, &block) statsd.time(metric, sample_rate, &block) end |
#timing(metric, value, sample_rate = 1) ⇒ Object
117 118 119 |
# File 'lib/maestro_metrics.rb', line 117 def timing(metric, value, sample_rate=1) statsd.timing(metric, value, sample_rate) end |