Class: Ruby::Reporters::Datadog
- Inherits:
-
Object
- Object
- Ruby::Reporters::Datadog
- Defined in:
- lib/ruby/reporters/datadog.rb
Instance Attribute Summary collapse
-
#default_http_tags ⇒ Object
readonly
Returns the value of attribute default_http_tags.
-
#response_time_metric_name ⇒ Object
readonly
Returns the value of attribute response_time_metric_name.
-
#statsd ⇒ Object
readonly
Returns the value of attribute statsd.
Instance Method Summary collapse
- #gauge(metric_name, value, tags) ⇒ Object
- #histogram(metric_name, value, tags) ⇒ Object
- #increment(metric_name, tags) ⇒ Object
-
#initialize(opts = {}) ⇒ Datadog
constructor
A new instance of Datadog.
- #response_time_ms(path, method, status, value) ⇒ Object
- #timing(metric_name, value, tags) ⇒ Object
Constructor Details
#initialize(opts = {}) ⇒ Datadog
Returns a new instance of Datadog.
8 9 10 11 12 13 14 15 16 17 |
# File 'lib/ruby/reporters/datadog.rb', line 8 def initialize(opts={}) statsd_host = opts[:statsd_host] || "localhost" statsd_port = opts[:statsd_port] || 8125 namespace = opts[:statsd_prefix] || nil @default_http_tags = ['type:http'] @response_time_metric_name = 'response_time_ms' @statsd = opts[:statsd] || ::Datadog::Statsd.new(statsd_host, statsd_port, namespace: namespace) end |
Instance Attribute Details
#default_http_tags ⇒ Object (readonly)
Returns the value of attribute default_http_tags.
6 7 8 |
# File 'lib/ruby/reporters/datadog.rb', line 6 def @default_http_tags end |
#response_time_metric_name ⇒ Object (readonly)
Returns the value of attribute response_time_metric_name.
6 7 8 |
# File 'lib/ruby/reporters/datadog.rb', line 6 def response_time_metric_name @response_time_metric_name end |
#statsd ⇒ Object (readonly)
Returns the value of attribute statsd.
6 7 8 |
# File 'lib/ruby/reporters/datadog.rb', line 6 def statsd @statsd end |
Instance Method Details
#gauge(metric_name, value, tags) ⇒ Object
29 30 31 32 33 34 35 |
# File 'lib/ruby/reporters/datadog.rb', line 29 def gauge(metric_name, value, ) statsd.gauge( metric_name, value, tags: ) end |
#histogram(metric_name, value, tags) ⇒ Object
44 45 46 47 48 49 50 |
# File 'lib/ruby/reporters/datadog.rb', line 44 def histogram(metric_name, value, ) statsd.histogram( metric_name, value, tags: ) end |
#increment(metric_name, tags) ⇒ Object
37 38 39 40 41 42 |
# File 'lib/ruby/reporters/datadog.rb', line 37 def increment(metric_name, ) statsd.increment( metric_name, tags: ) end |
#response_time_ms(path, method, status, value) ⇒ Object
19 20 21 22 23 24 25 26 27 |
# File 'lib/ruby/reporters/datadog.rb', line 19 def response_time_ms(path, method, status, value) = [ "route:#{method.upcase} #{path}", "status:#{status}", "error:#{from_status_to_error(status)}" ] histogram(response_time_metric_name, value, | ) end |
#timing(metric_name, value, tags) ⇒ Object
52 53 54 55 56 57 58 |
# File 'lib/ruby/reporters/datadog.rb', line 52 def timing(metric_name, value, ) statsd.timing( metric_name, value, tags: ) end |