Class: Alephant::Logger::CloudWatchDecorator
- Inherits:
-
Object
- Object
- Alephant::Logger::CloudWatchDecorator
- Defined in:
- lib/alephant/logger/cloudwatch_decorator.rb
Constant Summary collapse
- ONE_HOUR =
3600
Instance Method Summary collapse
-
#initialize(logger, namespace) ⇒ CloudWatchDecorator
constructor
A new instance of CloudWatchDecorator.
- #method_missing(name, *args) ⇒ Object
- #metric(opts) ⇒ Object
- #respond_to?(name) ⇒ Boolean
-
#warn(*args) ⇒ Object
Ruby’s Kernel implements a ‘warn` method.
Constructor Details
#initialize(logger, namespace) ⇒ CloudWatchDecorator
Returns a new instance of CloudWatchDecorator.
8 9 10 11 12 |
# File 'lib/alephant/logger/cloudwatch_decorator.rb', line 8 def initialize(logger, namespace) @logger = logger @namespace = namespace @cloudwatch = AWS::CloudWatch.new end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name, *args) ⇒ Object
35 36 37 |
# File 'lib/alephant/logger/cloudwatch_decorator.rb', line 35 def method_missing(name, *args) logger.send(name, *args) end |
Instance Method Details
#metric(opts) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/alephant/logger/cloudwatch_decorator.rb', line 14 def metric(opts) name, value, unit, dimensions = opts.values_at(:name, :value, :unit, :dimensions) Thread.new do cloudwatch.put_metric_data( :namespace => namespace, :metric_data => [{ :metric_name => name, :value => value, :unit => unit || "None", :dimensions => parse(dimensions || {}) }] ) end end |
#respond_to?(name) ⇒ Boolean
39 40 41 |
# File 'lib/alephant/logger/cloudwatch_decorator.rb', line 39 def respond_to?(name) logger.respond_to?(name) || super end |
#warn(*args) ⇒ Object
Ruby’s Kernel implements a ‘warn` method
31 32 33 |
# File 'lib/alephant/logger/cloudwatch_decorator.rb', line 31 def warn(*args) logger.warn(*args) end |