Class: Anomonitor::MetricPoint
- Inherits:
-
Struct
- Object
- Struct
- Anomonitor::MetricPoint
- Defined in:
- lib/anomonitor/metric_point.rb
Instance Attribute Summary collapse
-
#metric ⇒ Object
Returns the value of attribute metric.
-
#sampled_at ⇒ Object
Returns the value of attribute sampled_at.
-
#source ⇒ Object
Returns the value of attribute source.
-
#tags ⇒ Object
Returns the value of attribute tags.
-
#value ⇒ Object
Returns the value of attribute value.
Instance Method Summary collapse
- #cooldown_key ⇒ Object
-
#initialize(source:, metric:, value:, tags: {}, sampled_at: Time.current) ⇒ MetricPoint
constructor
A new instance of MetricPoint.
- #sticky? ⇒ Boolean
- #sticky_items_digest ⇒ Object
Constructor Details
#initialize(source:, metric:, value:, tags: {}, sampled_at: Time.current) ⇒ MetricPoint
Returns a new instance of MetricPoint.
7 8 9 10 11 12 13 14 15 |
# File 'lib/anomonitor/metric_point.rb', line 7 def initialize(source:, metric:, value:, tags: {}, sampled_at: Time.current) super( source: source.to_s, metric: metric.to_s, value: value.to_f, tags: || {}, sampled_at: sampled_at ) end |
Instance Attribute Details
#metric ⇒ Object
Returns the value of attribute metric
6 7 8 |
# File 'lib/anomonitor/metric_point.rb', line 6 def metric @metric end |
#sampled_at ⇒ Object
Returns the value of attribute sampled_at
6 7 8 |
# File 'lib/anomonitor/metric_point.rb', line 6 def sampled_at @sampled_at end |
#source ⇒ Object
Returns the value of attribute source
6 7 8 |
# File 'lib/anomonitor/metric_point.rb', line 6 def source @source end |
#tags ⇒ Object
Returns the value of attribute tags
6 7 8 |
# File 'lib/anomonitor/metric_point.rb', line 6 def @tags end |
#value ⇒ Object
Returns the value of attribute value
6 7 8 |
# File 'lib/anomonitor/metric_point.rb', line 6 def value @value end |
Instance Method Details
#cooldown_key ⇒ Object
21 22 23 24 25 26 27 28 29 30 |
# File 'lib/anomonitor/metric_point.rb', line 21 def cooldown_key tenant = [:tenant] || ["tenant"] queue = [:queue] || ["queue"] parts = [source, metric, tenant, queue] if sticky? digest = sticky_items_digest parts << digest if digest end parts.compact.join(":") end |
#sticky? ⇒ Boolean
17 18 19 |
# File 'lib/anomonitor/metric_point.rb', line 17 def sticky? source == "schema_drift" end |
#sticky_items_digest ⇒ Object
32 33 34 35 36 37 38 39 40 |
# File 'lib/anomonitor/metric_point.rb', line 32 def sticky_items_digest digest = [:items_digest] || ["items_digest"] return digest.to_s if digest && !digest.to_s.empty? items = [:items] || ["items"] return nil if items.nil? || items.to_s.empty? Digest::SHA256.hexdigest(items.to_s)[0, 16] end |