Class: ElasticAPM::Transport::Serializers::SpanSerializer Private

Inherits:
Serializer
  • Object
show all
Defined in:
lib/elastic_apm/transport/serializers/span_serializer.rb

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Defined Under Namespace

Classes: ContextSerializer

Instance Attribute Summary collapse

Attributes inherited from Serializer

#config

Instance Method Summary collapse

Constructor Details

#initialize(config) ⇒ SpanSerializer

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of SpanSerializer.



25
26
27
28
29
# File 'lib/elastic_apm/transport/serializers/span_serializer.rb', line 25

def initialize(config)
  super

  @context_serializer = ContextSerializer.new(config)
end

Instance Attribute Details

#context_serializerObject (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



31
32
33
# File 'lib/elastic_apm/transport/serializers/span_serializer.rb', line 31

def context_serializer
  @context_serializer
end

Instance Method Details

#build(span) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/elastic_apm/transport/serializers/span_serializer.rb', line 33

def build(span)
  {
    span: {
      id: span.id,
      transaction_id: span.transaction.id,
      parent_id: span.parent_id,
      name: keyword_field(span.name),
      type: join_type(span),
      duration: ms(span.duration),
      context: context_serializer.build(span.context),
      stacktrace: span.stacktrace.to_a,
      timestamp: span.timestamp,
      trace_id: span.trace_id,
      sample_rate: span.sample_rate,
      outcome: keyword_field(span.outcome)
    }
  }
end