Class: Honeybadger::Metric
- Inherits:
-
Object
- Object
- Honeybadger::Metric
show all
- Defined in:
- lib/honeybadger/metric.rb
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Constructor Details
#initialize(name, attributes) ⇒ Metric
Returns a new instance of Metric.
18
19
20
21
22
|
# File 'lib/honeybadger/metric.rb', line 18
def initialize(name, attributes)
@name = name
@attributes = attributes || {}
@samples = 0
end
|
Instance Attribute Details
#attributes ⇒ Object
Returns the value of attribute attributes.
3
4
5
|
# File 'lib/honeybadger/metric.rb', line 3
def attributes
@attributes
end
|
#name ⇒ Object
Returns the value of attribute name.
3
4
5
|
# File 'lib/honeybadger/metric.rb', line 3
def name
@name
end
|
#samples ⇒ Object
Returns the value of attribute samples.
3
4
5
|
# File 'lib/honeybadger/metric.rb', line 3
def samples
@samples
end
|
Class Method Details
.metric_type ⇒ Object
5
6
7
|
# File 'lib/honeybadger/metric.rb', line 5
def self.metric_type
name.split('::').last.downcase
end
|
.register(registry, metric_name, attributes) ⇒ Object
13
14
15
16
|
# File 'lib/honeybadger/metric.rb', line 13
def self.register(registry, metric_name, attributes)
registry.get(metric_type, metric_name, attributes) ||
registry.register(new(metric_name, attributes))
end
|
.signature(metric_type, name, attributes) ⇒ Object
9
10
11
|
# File 'lib/honeybadger/metric.rb', line 9
def self.signature(metric_type, name, attributes)
Digest::SHA1.hexdigest("#{metric_type}-#{name}-#{attributes.keys.join('-')}-#{attributes.values.join('-')}").to_sym
end
|
Instance Method Details
#base_payload ⇒ Object
32
33
34
35
36
37
38
39
|
# File 'lib/honeybadger/metric.rb', line 32
def base_payload
attributes.merge({
event_type: "metric.hb",
metric_name: name,
metric_type: metric_type,
samples: samples
})
end
|
#event_payloads ⇒ Object
41
42
43
44
45
|
# File 'lib/honeybadger/metric.rb', line 41
def event_payloads
payloads.map do |payload|
base_payload.merge(payload)
end
end
|
#metric_type ⇒ Object
24
25
26
|
# File 'lib/honeybadger/metric.rb', line 24
def metric_type
self.class.metric_type
end
|
#signature ⇒ Object
28
29
30
|
# File 'lib/honeybadger/metric.rb', line 28
def signature
self.class.signature(metric_type, name, attributes)
end
|