Class: Maze::Api::Model::OtelAttribute
- Inherits:
-
Object
- Object
- Maze::Api::Model::OtelAttribute
- Defined in:
- lib/maze/api/model/otel_attribute.rb
Overview
OTEL attributes used in both spans and resources
Instance Attribute Summary collapse
-
#key ⇒ Object
Returns the value of attribute key.
-
#type ⇒ Object
Returns the value of attribute type.
-
#value ⇒ Object
Returns the value of attribute value.
Class Method Summary collapse
-
.array_from_hash(hash_array) ⇒ Array<OtelAttributeArrayElement>
Create an array of OtelAttributeArrayElement from a hash array.
-
.from_hash(hash) ⇒ OtelAttribute
Create an OtelAttribute from a hash.
Instance Method Summary collapse
-
#initialize(type, key, value) ⇒ OtelAttribute
constructor
A new instance of OtelAttribute.
Constructor Details
#initialize(type, key, value) ⇒ OtelAttribute
Returns a new instance of OtelAttribute.
21 22 23 24 25 |
# File 'lib/maze/api/model/otel_attribute.rb', line 21 def initialize(type, key, value) @key = key @type = type @value = value end |
Instance Attribute Details
#key ⇒ Object
Returns the value of attribute key.
19 20 21 |
# File 'lib/maze/api/model/otel_attribute.rb', line 19 def key @key end |
#type ⇒ Object
Returns the value of attribute type.
19 20 21 |
# File 'lib/maze/api/model/otel_attribute.rb', line 19 def type @type end |
#value ⇒ Object
Returns the value of attribute value.
19 20 21 |
# File 'lib/maze/api/model/otel_attribute.rb', line 19 def value @value end |
Class Method Details
.array_from_hash(hash_array) ⇒ Array<OtelAttributeArrayElement>
Create an array of OtelAttributeArrayElement from a hash array.
31 32 33 34 35 36 37 38 39 |
# File 'lib/maze/api/model/otel_attribute.rb', line 31 def array_from_hash(hash_array) array = [] hash_array.each do |value_hash| type = OtelAttributeType::for_string(value_hash.keys.first) value = value_hash.values.first array << OtelAttributeArrayElement.new(type, value) end array end |
.from_hash(hash) ⇒ OtelAttribute
Create an OtelAttribute from a hash.
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/maze/api/model/otel_attribute.rb', line 44 def from_hash(hash) type = OtelAttributeType.for_string(hash['value'].keys.first) hash_value = hash['value'] value = if hash_value.has_key?('arrayValue') array_from_hash(hash_value['arrayValue']['values']) elsif hash_value.has_key?('boolValue') hash_value['boolValue'] elsif hash_value.has_key?('doubleValue') hash_value['doubleValue'] elsif hash_value.has_key?('intValue') hash_value['intValue'] elsif hash_value.has_key?('stringValue') hash_value['stringValue'] end new( type, hash['key'], value ) end |