Module: Maestro::Metrics
- Defined in:
- lib/maestro_metrics.rb,
lib/maestro_metrics/version.rb
Defined Under Namespace
Classes: Real
Constant Summary collapse
- VERSION =
'0.0.7'
Class Method Summary collapse
- .aggregate(collection, pipeline = nil) ⇒ Object
- .collection_names ⇒ Object
- .configure(config = {}) ⇒ 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
- .log(collection, metrics) ⇒ Object
- .mock! ⇒ Object
- .mock? ⇒ Boolean
- .mocking? ⇒ Boolean
- .time(metric, sample_rate = 1, &block) ⇒ Object
- .timing(metric, value, sample_rate = 1) ⇒ Object
- .to_mongo(value) ⇒ Object
- .unmock! ⇒ Object
Class Method Details
.aggregate(collection, pipeline = nil) ⇒ Object
57 58 59 |
# File 'lib/maestro_metrics.rb', line 57 def Metrics.aggregate(collection, pipeline=nil) logger.aggregate(collection, pipeline) end |
.collection_names ⇒ Object
85 86 87 |
# File 'lib/maestro_metrics.rb', line 85 def Metrics.collection_names logger.collection_names end |
.configure(config = {}) ⇒ Object
29 30 31 |
# File 'lib/maestro_metrics.rb', line 29 def self.configure(config={}) @config = config unless config.nil? end |
.count(metric, value, sample_rate = 1) ⇒ Object
33 34 35 |
# File 'lib/maestro_metrics.rb', line 33 def Metrics.count(metric, value, sample_rate=1) logger.count(metric, value, sample_rate) end |
.decrement(metric, sample_rate = 1) ⇒ Object
45 46 47 |
# File 'lib/maestro_metrics.rb', line 45 def Metrics.decrement(metric, sample_rate=1) logger.decrement(metric, sample_rate) end |
.find(collection, selector = {}, opts = {}) ⇒ Object
61 62 63 |
# File 'lib/maestro_metrics.rb', line 61 def Metrics.find(collection, selector={}, opts={}) logger.find(collection, selector, opts) end |
.increment(metric, sample_rate = 1) ⇒ Object
41 42 43 |
# File 'lib/maestro_metrics.rb', line 41 def Metrics.increment(metric, sample_rate=1) logger.increment(metric, sample_rate) end |
.log(collection, metrics) ⇒ Object
53 54 55 |
# File 'lib/maestro_metrics.rb', line 53 def Metrics.log(collection, metrics) logger.log(collection, metrics) end |
.mock! ⇒ Object
13 14 15 |
# File 'lib/maestro_metrics.rb', line 13 def Metrics.mock! @mocking = true end |
.mocking? ⇒ Boolean
25 26 27 |
# File 'lib/maestro_metrics.rb', line 25 def Metrics.mocking? @mocking end |
.time(metric, sample_rate = 1, &block) ⇒ Object
49 50 51 |
# File 'lib/maestro_metrics.rb', line 49 def Metrics.time(metric, sample_rate=1, &block) logger.time(metric, sample_rate, &block) end |
.timing(metric, value, sample_rate = 1) ⇒ Object
37 38 39 |
# File 'lib/maestro_metrics.rb', line 37 def Metrics.timing(metric, value, sample_rate=1) logger.timing(metric, value, sample_rate) end |
.to_mongo(value) ⇒ Object
65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 |
# File 'lib/maestro_metrics.rb', line 65 def Metrics.to_mongo(value) if value.nil? || value == '' nil else time = nil if value.is_a?(::Date) time = value.to_time elsif value.is_a?(::Time) time = value else time = ::Time.parse(value.to_s) end time.utc end rescue nil end |
.unmock! ⇒ Object
17 18 19 |
# File 'lib/maestro_metrics.rb', line 17 def Metrics.unmock! @mocking = false end |