Module: Appsignal::Helpers::Metrics

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

Instance Method Summary collapse

Instance Method Details

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

Report a distribution metric.

Parameters:

  • name (String, Symbol)

    The name of the metric.

  • value (Integer, Float)

    The value of the metric.

  • tags (Hash) (defaults to: {})

    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 Also:

Since:

  • 2.6.0



61
62
63
64
65
66
67
68
69
70
# File 'lib/appsignal/helpers/metrics.rb', line 61

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 = {}) ⇒ Object

Report a counter metric.

Parameters:

  • name (String, Symbol)

    The name of the metric.

  • value (Integer, Float) (defaults to: 1.0)

    The value of the metric.

  • tags (Hash) (defaults to: {})

    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 Also:

Since:

  • 2.6.0



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

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 = {}) ⇒ Object

Report a gauge metric.

Parameters:

  • name (String, Symbol)

    The name of the metric.

  • value (Integer, Float)

    The value of the metric.

  • tags (Hash) (defaults to: {})

    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 Also:

Since:

  • 2.6.0



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

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