Method: SolarWindsAPM::API::CustomMetrics#increment_metric
- Defined in:
- lib/solarwinds_apm/api/custom_metrics.rb
#increment_metric(name, count = 1, with_hostname = false, tags_kvs = {}) ⇒ Object
Send counts
Use this method to report the number of times an action occurs. The metric counts reported are summed and flushed every 60 seconds.
Arguments:
-
name
(String) Name to be used for the metric. Must be 255 or fewer characters and consist only of A-Za-z0-9.:-* -
count
(Integer, optional, default = 1): Count of actions being reported -
with_hostname
(Boolean, optional, default = false): Indicates if the host name should be included as a tag for the metric -
tags_kvs
(Hash, optional): List of key/value pairs to describe the metric. The key must be <= 64 characters, the value must be <= 255 characters, allowed characters: A-Za-z0-9.:-_
Example:
class WorkTracker
def counting(name, = {})
yield # yield to where work is done
SolarWindsAPM::API.increment_metric(name, 1, false, )
end
end
Returns:
-
Boolean
35 36 37 38 39 40 41 |
# File 'lib/solarwinds_apm/api/custom_metrics.rb', line 35 def increment_metric(name, count = 1, with_hostname = false, = {}) # rubocop:disable Style/OptionalBooleanParameter return true unless SolarWindsAPM.loaded with_hostname = with_hostname ? 1 : 0 , = () SolarWindsAPM::CustomMetrics.increment(name.to_s, count, with_hostname, nil, , ).zero? end |