Class: Flare::MetricKey
- Inherits:
-
Object
- Object
- Flare::MetricKey
- Defined in:
- lib/flare/metric_key.rb
Overview
Identifies a unique metric for aggregation. Immutable and hashable for use as Concurrent::Map keys.
Instance Attribute Summary collapse
-
#bucket ⇒ Object
readonly
Returns the value of attribute bucket.
-
#namespace ⇒ Object
readonly
Returns the value of attribute namespace.
-
#operation ⇒ Object
readonly
Returns the value of attribute operation.
-
#service ⇒ Object
readonly
Returns the value of attribute service.
-
#target ⇒ Object
readonly
Returns the value of attribute target.
Instance Method Summary collapse
- #eql?(other) ⇒ Boolean (also: #==)
- #hash ⇒ Object
-
#initialize(bucket:, namespace:, service:, target:, operation:) ⇒ MetricKey
constructor
A new instance of MetricKey.
- #to_h ⇒ Object
Constructor Details
#initialize(bucket:, namespace:, service:, target:, operation:) ⇒ MetricKey
Returns a new instance of MetricKey.
9 10 11 12 13 14 15 16 |
# File 'lib/flare/metric_key.rb', line 9 def initialize(bucket:, namespace:, service:, target:, operation:) @bucket = bucket @namespace = namespace.to_s.freeze @service = service.to_s.freeze @target = target&.to_s&.freeze @operation = operation.to_s.freeze freeze end |
Instance Attribute Details
#bucket ⇒ Object (readonly)
Returns the value of attribute bucket.
7 8 9 |
# File 'lib/flare/metric_key.rb', line 7 def bucket @bucket end |
#namespace ⇒ Object (readonly)
Returns the value of attribute namespace.
7 8 9 |
# File 'lib/flare/metric_key.rb', line 7 def namespace @namespace end |
#operation ⇒ Object (readonly)
Returns the value of attribute operation.
7 8 9 |
# File 'lib/flare/metric_key.rb', line 7 def operation @operation end |
#service ⇒ Object (readonly)
Returns the value of attribute service.
7 8 9 |
# File 'lib/flare/metric_key.rb', line 7 def service @service end |
#target ⇒ Object (readonly)
Returns the value of attribute target.
7 8 9 |
# File 'lib/flare/metric_key.rb', line 7 def target @target end |
Instance Method Details
#eql?(other) ⇒ Boolean Also known as: ==
18 19 20 21 22 23 24 25 |
# File 'lib/flare/metric_key.rb', line 18 def eql?(other) self.class.eql?(other.class) && bucket == other.bucket && namespace == other.namespace && service == other.service && target == other.target && operation == other.operation end |
#hash ⇒ Object
28 29 30 |
# File 'lib/flare/metric_key.rb', line 28 def hash [self.class, bucket, namespace, service, target, operation].hash end |
#to_h ⇒ Object
32 33 34 35 36 37 38 39 40 |
# File 'lib/flare/metric_key.rb', line 32 def to_h { bucket: bucket, namespace: namespace, service: service, target: target, operation: operation } end |