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

This method returns an undefined value.

Report a distribution metric.

Parameters:

  • name (String, Symbol)

    The name of the metric.

  • value (Integer, Float)

    The value of the metric.

  • tags (Hash<String, Object>) (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



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.

Parameters:

  • name (String, Symbol)

    The name of the metric.

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

    The value of the metric.

  • tags (Hash<String, Object>) (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



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.

Parameters:

  • name (String, Symbol)

    The name of the metric.

  • value (Integer, Float)

    The value of the metric.

  • tags (Hash<String, Object>) (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



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