Class: Deimos::Metrics::Datadog
- Defined in:
- lib/deimos/metrics/datadog.rb
Overview
A Metrics wrapper class for Datadog.
Instance Method Summary collapse
-
#gauge(metric_name, count, options = {}) ⇒ Object
:nodoc:.
-
#histogram(metric_name, count, options = {}) ⇒ Object
:nodoc:.
-
#increment(metric_name, options = {}) ⇒ Object
:nodoc:.
-
#initialize(config, logger) ⇒ Datadog
constructor
A new instance of Datadog.
-
#time(metric_name, options = {}) ⇒ Object
:nodoc:.
Constructor Details
#initialize(config, logger) ⇒ Datadog
Returns a new instance of Datadog.
11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/deimos/metrics/datadog.rb', line 11 def initialize(config, logger) raise 'Metrics config must specify host_ip' if config[:host_ip].nil? raise 'Metrics config must specify host_port' if config[:host_port].nil? raise 'Metrics config must specify namespace' if config[:namespace].nil? logger.info("DatadogMetricsProvider configured with: #{config}") @client = ::Datadog::Statsd.new( config[:host_ip], config[:host_port], tags: config[:tags], namespace: config[:namespace] ) end |
Instance Method Details
#gauge(metric_name, count, options = {}) ⇒ Object
:nodoc:
33 34 35 |
# File 'lib/deimos/metrics/datadog.rb', line 33 def gauge(metric_name, count, ={}) @client.gauge(metric_name, count, ) end |
#histogram(metric_name, count, options = {}) ⇒ Object
:nodoc:
38 39 40 |
# File 'lib/deimos/metrics/datadog.rb', line 38 def histogram(metric_name, count, ={}) @client.histogram(metric_name, count, ) end |
#increment(metric_name, options = {}) ⇒ Object
:nodoc:
27 28 29 30 |
# File 'lib/deimos/metrics/datadog.rb', line 27 def increment(metric_name, ={}) Rails.logger.info("Incrementing #{metric_name} #{}") @client.increment(metric_name, ) end |
#time(metric_name, options = {}) ⇒ Object
:nodoc:
43 44 45 46 47 |
# File 'lib/deimos/metrics/datadog.rb', line 43 def time(metric_name, ={}) @client.time(metric_name, ) do yield end end |