Class: Arcp::Job::EventBody::TraceSpan

Inherits:
Data
  • Object
show all
Defined in:
lib/arcp/job/event_body/trace_span.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#attributesObject (readonly)

Returns the value of attribute attributes

Returns:

  • (Object)

    the current value of attributes



6
7
8
# File 'lib/arcp/job/event_body/trace_span.rb', line 6

def attributes
  @attributes
end

#end_atObject (readonly)

Returns the value of attribute end_at

Returns:

  • (Object)

    the current value of end_at



6
7
8
# File 'lib/arcp/job/event_body/trace_span.rb', line 6

def end_at
  @end_at
end

#nameObject (readonly)

Returns the value of attribute name

Returns:

  • (Object)

    the current value of name



6
7
8
# File 'lib/arcp/job/event_body/trace_span.rb', line 6

def name
  @name
end

#parent_span_idObject (readonly)

Returns the value of attribute parent_span_id

Returns:

  • (Object)

    the current value of parent_span_id



6
7
8
# File 'lib/arcp/job/event_body/trace_span.rb', line 6

def parent_span_id
  @parent_span_id
end

#span_idObject (readonly)

Returns the value of attribute span_id

Returns:

  • (Object)

    the current value of span_id



6
7
8
# File 'lib/arcp/job/event_body/trace_span.rb', line 6

def span_id
  @span_id
end

#start_atObject (readonly)

Returns the value of attribute start_at

Returns:

  • (Object)

    the current value of start_at



6
7
8
# File 'lib/arcp/job/event_body/trace_span.rb', line 6

def start_at
  @start_at
end

Class Method Details

.from_h(h) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
# File 'lib/arcp/job/event_body/trace_span.rb', line 7

def self.from_h(h)
  h = h.transform_keys(&:to_s)
  new(
    span_id: h.fetch('span_id'),
    parent_span_id: h['parent_span_id'],
    name: h.fetch('name'),
    start_at: h['start_at'],
    end_at: h['end_at'],
    attributes: h['attributes'] || {}
  )
end

Instance Method Details

#to_hObject



19
20
21
22
23
24
25
26
# File 'lib/arcp/job/event_body/trace_span.rb', line 19

def to_h
  out = { 'span_id' => span_id, 'name' => name }
  out['parent_span_id'] = parent_span_id if parent_span_id
  out['start_at']       = start_at if start_at
  out['end_at']         = end_at if end_at
  out['attributes']     = attributes unless attributes.empty?
  out
end