Class: Maze::Api::Model::Span

Inherits:
Object
  • Object
show all
Defined in:
lib/maze/api/model/span.rb

Overview

A single OTEL span.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeSpan

Returns a new instance of Span.



12
13
14
15
16
17
18
# File 'lib/maze/api/model/span.rb', line 12

def initialize
  @attributes = {}

  def add_attribute(attribute)
    @attributes[attribute.key] = attribute
  end
end

Instance Attribute Details

#attributesObject

Returns the value of attribute attributes.



10
11
12
# File 'lib/maze/api/model/span.rb', line 10

def attributes
  @attributes
end

#end_timeObject

Returns the value of attribute end_time.



10
11
12
# File 'lib/maze/api/model/span.rb', line 10

def end_time
  @end_time
end

#idObject

Returns the value of attribute id.



10
11
12
# File 'lib/maze/api/model/span.rb', line 10

def id
  @id
end

#kindObject

Returns the value of attribute kind.



10
11
12
# File 'lib/maze/api/model/span.rb', line 10

def kind
  @kind
end

#nameObject

Returns the value of attribute name.



10
11
12
# File 'lib/maze/api/model/span.rb', line 10

def name
  @name
end

#start_timeObject

Returns the value of attribute start_time.



10
11
12
# File 'lib/maze/api/model/span.rb', line 10

def start_time
  @start_time
end

#trace_idObject

Returns the value of attribute trace_id.



10
11
12
# File 'lib/maze/api/model/span.rb', line 10

def trace_id
  @trace_id
end

Class Method Details

.from_hash(hash) ⇒ Span

Create a Span from a hash.

Parameters:

  • hash (Hash)

    Hash representing an OTEL span.

Returns:

  • (Span)

    Span object.



24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/maze/api/model/span.rb', line 24

def from_hash(hash)
  span = new
  span.id = hash['spanId']
  span.kind = hash['kind']
  span.name = hash['name']
  span.trace_id = hash['traceId']
  span.start_time = hash['startTimeUnixNano']
  span.end_time = hash['endTimeUnixNano']

  hash['attributes'].each do |attribute_hash|
    attribute = OtelAttribute.from_hash(attribute_hash)
    span.add_attribute(attribute)
  end

  span
end

Instance Method Details

#add_attribute(attribute) ⇒ Object



15
16
17
# File 'lib/maze/api/model/span.rb', line 15

def add_attribute(attribute)
  @attributes[attribute.key] = attribute
end