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.



8
9
10
11
12
# File 'lib/elastic_apm/transport/serializers/span_serializer.rb', line 8

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.



14
15
16
# File 'lib/elastic_apm/transport/serializers/span_serializer.rb', line 14

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.

rubocop:disable Metrics/MethodLength, Metrics/AbcSize



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/elastic_apm/transport/serializers/span_serializer.rb', line 17

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