Module: BetterFx::Measurement::ClassMethods

Defined in:
lib/better_fx/measurement.rb

Overview

Class methods

Instance Method Summary collapse

Instance Method Details

#bfxBetterFx::Client

A memoized BetterFx Client instance

Returns:



52
53
54
# File 'lib/better_fx/measurement.rb', line 52

def bfx
  @_bfx ||= BetterFx::Client.new
end

#gauge_name(measurement_name) ⇒ Object

Generates the fully qualified gauge name

Parameters:

  • measurement_name (String, Symbol)

    the name of the measurement



59
60
61
# File 'lib/better_fx/measurement.rb', line 59

def gauge_name(measurement_name)
  "#{BetterFx.configuration.signalfx_metric_namespace}.#{name.to_s.underscore.downcase}.#{measurement_name}".tr "/", "."
end

#measurement(name, _opts = {}, &blk) ⇒ Object

Defines a measurement

Parameters:

  • name (String, Symbol)

    the name of the measurement (measurement names are inherently namespaced by class so should just use a meaningful name. It will show up in the telemetry system as gauge.$CLASS.name)

  • blk (Block)

    you must provide a block which contains the code for performing the measurement; the block must return the value of the measurement



36
37
38
39
40
# File 'lib/better_fx/measurement.rb', line 36

def measurement(name, _opts = {}, &blk)
  name = name.to_s
  @_measurements ||= {}
  @_measurements[name] = blk
end

#measurementsHash

Returns all of the defined measurements

Returns:

  • (Hash)

    the measurements with names as keys and procs as values



45
46
47
# File 'lib/better_fx/measurement.rb', line 45

def measurements
  @_measurements
end