Module: InstStatsd::Distribution
- Included in:
- Statsd
- Defined in:
- lib/inst_statsd/distribution.rb
Overview
Mix-in methods for supporting DataDog events See docs.datadoghq.com/metrics/types/?tab=distribution#metric-types
Instance Method Summary collapse
-
#distributed_increment(metric, tags: {}, short_stat: nil) ⇒ Object
Increments the specified distribution metric by 1.
-
#distribution(metric, value, tags: {}) ⇒ Object
Sends a distribution metric to DataDog if the instance and DataDog are configured.
Instance Method Details
#distributed_increment(metric, tags: {}, short_stat: nil) ⇒ Object
Increments the specified distribution metric by 1.
39 40 41 42 43 44 |
# File 'lib/inst_statsd/distribution.rb', line 39 def distributed_increment(metric, tags: {}, short_stat: nil) # Non-Datadog clients don't support distribution metrics, so we use fall back to increment return increment(metric, tags: , short_stat: short_stat) if instance && !data_dog? distribution(short_stat || metric, 1, tags: ) end |
#distribution(metric, value, tags: {}) ⇒ Object
Sends a distribution metric to DataDog if the instance and DataDog are configured.
Distributions are aggregated globally and are appropriate when a metric sourced from multiple hosts need to be considered in a global statistical distribution.
18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/inst_statsd/distribution.rb', line 18 def distribution(metric, value, tags: {}) return unless instance && data_dog? metric = if append_hostname? "#{metric}.#{hostname}" else metric.to_s end = .merge() if .is_a?(Hash) instance.distribution(metric, value, { tags: }) end |