Module: Appsignal::Helpers::Metrics

Included in:
Appsignal
Defined in:
lib/appsignal/helpers/metrics.rb,
sig/appsignal.rbs

Instance Method Summary collapse

Instance Method Details

#add_distribution_value(name, value, tags = {}) ⇒ void

This method returns an undefined value.

Report a distribution metric.

@param name — The name of the metric.

@param value — The value of the metric.

@param tags — The tags for the metric. The Hash keys can be either a String or a Symbol. The tag values can be a String, Symbol, Integer, Float, TrueClass or FalseClass.

@see https://docs.appsignal.com/metrics/custom.html — Metrics documentation

Parameters:

  • name (String, Symbol)
  • value (Integer, Float)
  • tags (::Hash[String, Object]) (defaults to: {})


64
65
66
67
68
69
70
71
72
73
# File 'lib/appsignal/helpers/metrics.rb', line 64

def add_distribution_value(name, value, tags = {})
  Appsignal::Extension.add_distribution_value(
    name.to_s,
    value.to_f,
    Appsignal::Utils::Data.generate(tags)
  )
rescue RangeError
  Appsignal.internal_logger
    .warn("The distribution value '#{value}' for metric '#{name}' is too big")
end

#increment_counter(name, value = 1.0, tags = {}) ⇒ void

This method returns an undefined value.

Report a counter metric.

@param name — The name of the metric.

@param value — The value of the metric.

@param tags — The tags for the metric. The Hash keys can be either a String or a Symbol. The tag values can be a String, Symbol, Integer, Float, TrueClass or FalseClass.

@see https://docs.appsignal.com/metrics/custom.html — Metrics documentation

Parameters:

  • name (String, Symbol)
  • value (?(Integer | Float)) (defaults to: 1.0)
  • tags (::Hash[String, Object]) (defaults to: {})


41
42
43
44
45
46
47
48
49
50
# File 'lib/appsignal/helpers/metrics.rb', line 41

def increment_counter(name, value = 1.0, tags = {})
  Appsignal::Extension.increment_counter(
    name.to_s,
    value.to_f,
    Appsignal::Utils::Data.generate(tags)
  )
rescue RangeError
  Appsignal.internal_logger
    .warn("The counter value '#{value}' for metric '#{name}' is too big")
end

#set_gauge(name, value, tags = {}) ⇒ void

This method returns an undefined value.

Report a gauge metric.

@param name — The name of the metric.

@param value — The value of the metric.

@param tags — The tags for the metric. The Hash keys can be either a String or a Symbol. The tag values can be a String, Symbol, Integer, Float, TrueClass or FalseClass.

@see https://docs.appsignal.com/metrics/custom.html — Metrics documentation

Parameters:

  • name (String, Symbol)
  • value (Integer, Float)
  • tags (::Hash[String, Object]) (defaults to: {})


18
19
20
21
22
23
24
25
26
27
# File 'lib/appsignal/helpers/metrics.rb', line 18

def set_gauge(name, value, tags = {})
  Appsignal::Extension.set_gauge(
    name.to_s,
    value.to_f,
    Appsignal::Utils::Data.generate(tags)
  )
rescue RangeError
  Appsignal.internal_logger
    .warn("The gauge value '#{value}' for metric '#{name}' is too big")
end