Class: Honeycomb::Trace

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Includes:
RollupFields
Defined in:
lib/honeycomb/trace.rb

Overview

Represents a Honeycomb trace, which groups spans together

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from RollupFields

#add_rollup_field, #rollup_fields

Constructor Details

#initialize(builder:, context:, serialized_trace: nil, **options) ⇒ Trace

Returns a new instance of Trace.



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/honeycomb/trace.rb', line 19

def initialize(builder:, context:, serialized_trace: nil, **options)
  trace_id, parent_span_id, trace_fields, dataset =
    internal_parse(context: context, serialized_trace: serialized_trace, **options)

  # if dataset is not nil,
  # set trace's builder.dataset = dataset from trace header
  if context.classic?
    dataset && builder.dataset = dataset
  end

  @id = trace_id || generate_trace_id
  @fields = trace_fields || {}
  @root_span = Span.new(trace: self,
                        parent_id: parent_span_id,
                        is_root: true,
                        builder: builder,
                        context: context,
                        **options)
end

Instance Attribute Details

#fieldsObject (readonly)

Returns the value of attribute fields.



17
18
19
# File 'lib/honeycomb/trace.rb', line 17

def fields
  @fields
end

#idObject (readonly)

Returns the value of attribute id.



17
18
19
# File 'lib/honeycomb/trace.rb', line 17

def id
  @id
end

#root_spanObject (readonly)

Returns the value of attribute root_span.



17
18
19
# File 'lib/honeycomb/trace.rb', line 17

def root_span
  @root_span
end

Instance Method Details

#add_field(key, value) ⇒ Object



39
40
41
# File 'lib/honeycomb/trace.rb', line 39

def add_field(key, value)
  @fields[key] = value
end