Sha256: f9ce5b4b35820ee0329193bf84eb53be3c2525ad5c1dbc73257fe4d46509e3e5
Contents?: true
Size: 1.06 KB
Versions: 34
Compression:
Stored size: 1.06 KB
Contents
module Honeybadger class Metric attr_reader :name, :attributes, :samples def self.metric_type name.split('::').last.downcase end def self.signature(metric_type, name, attributes) Digest::SHA1.hexdigest("#{metric_type}-#{name}-#{attributes.keys.join('-')}-#{attributes.values.join('-')}").to_sym end def self.register(registry, metric_name, attributes) registry.get(metric_type, metric_name, attributes) || registry.register(new(metric_name, attributes)) end def initialize(name, attributes) @name = name @attributes = attributes || {} @samples = 0 end def metric_type self.class.metric_type end def signature self.class.signature(metric_type, name, attributes) end def base_payload attributes.merge({ event_type: "metric.hb", metric_name: name, metric_type: metric_type, samples: samples }) end def event_payloads payloads.map do |payload| base_payload.merge(payload) end end end end
Version data entries
34 entries across 34 versions & 1 rubygems