Module: SolarWindsAPM::API::CustomMetrics

Defined in:
lib/solarwinds_apm/api/custom_metrics.rb

Instance Method Summary collapse

Instance Method Details

#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, tags = {})
    yield # yield to where work is done
    SolarWindsAPM::API.increment_metric(name, 1, false, tags)
  end
end

Returns:

  • Boolean



35
36
37
38
# File 'lib/solarwinds_apm/api/custom_metrics.rb', line 35

def increment_metric(_name, _count = 1, _with_hostname = false, _tags_kvs = {}) # rubocop:disable Style/OptionalBooleanParameter
  SolarWindsAPM.logger.warn { 'increment_metric is deprecated, please use the OpenTelemetry API instead.' }
  false
end

#summary_metric(_name, _value, _count = 1, _with_hostname = false, _tags_kvs = {}) ⇒ Object

Send values with counts

Use this method to report a value for each or multiple counts. The metric values reported are aggregated and flushed every 60 seconds. The dashboard displays the average value per count.

Arguments:

  • name (String) Name to be used for the metric. Must be 255 or fewer characters and consist only of A-Za-z0-9.:-*

  • value (Numeric) Value to be added to the current sum

  • 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 timing(name, tags = {})
    start = Time.now
    yield # yield to where work is done
    duration = Time.now - start
    SolarWindsAPM::API.summary_metric(name, duration, 1, false, tags)
  end
end

Returns:

  • Boolean



66
67
68
69
# File 'lib/solarwinds_apm/api/custom_metrics.rb', line 66

def summary_metric(_name, _value, _count = 1, _with_hostname = false, _tags_kvs = {}) # rubocop:disable Style/OptionalBooleanParameter
  SolarWindsAPM.logger.warn { 'summary_metric is deprecated, please use the OpenTelemetry API instead.' }
  false
end