Sha256: 5569193ed820219b54e7820d3bedb94ea8e436f40d999907004853727e1f5cca
Contents?: true
Size: 752 Bytes
Versions: 1
Compression:
Stored size: 752 Bytes
Contents
class Yodeler::Metric attr_reader :type, :value attr_reader :sample_rate, :tags, :prefix attr_reader :options def initialize(type, name, value, opts={}) @type = type @name = name @value = value @prefix = opts.delete(:prefix) @sample_rate = opts.delete(:sample_rate) @options = opts end def name @prefix ? [@prefix, @name].join('.') : @name end # @return [Boolean] Should this metric be sampled def sample? @_sample ||= !(rand()> @sample_rate) end def to_hash hash = { name: name, type: @type, value: @value, } hash[:tags] = options[:tags] if options[:tags] && options[:tags].any? hash[:hostname] = options[:hostname] if options[:hostname] hash end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
yodeler-0.1.1 | lib/yodeler/metric.rb |