module BetterFx::Measurement::ClassMethods

Class methods

Public Instance Methods

bfx() click to toggle source

A memoized BetterFx Client instance

@return [BetterFx::Client] a BetterFx client

# File lib/better_fx/measurement.rb, line 52
def bfx
  @_bfx ||= BetterFx::Client.new
end
gauge_name(measurement_name) click to toggle source

Generates the fully qualified gauge name

@param measurement_name [String, Symbol] the name of the measurement

# 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) click to toggle source

Defines a measurement

@param 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)

@param blk [Block] you must provide a block which contains the code for performing

the measurement; the block must return the value of the measurement
# File lib/better_fx/measurement.rb, line 36
def measurement(name, _opts = {}, &blk)
  name = name.to_s
  @_measurements ||= {}
  @_measurements[name] = blk
end
measurements() click to toggle source

Returns all of the defined measurements

@return [Hash] the measurements with names as keys and procs as values

# File lib/better_fx/measurement.rb, line 45
def measurements
  @_measurements
end