Module: Datadog::Encoding::Encoder

Included in:
JSONEncoder, MsgpackEncoder
Defined in:
lib/ddtrace/encoding.rb

Overview

Encoder interface that provides the logic to encode traces and service

Instance Method Summary collapse

Instance Method Details

#content_typeObject

Raises:

  • (NotImplementedError)


9
10
11
# File 'lib/ddtrace/encoding.rb', line 9

def content_type
  raise NotImplementedError
end

#encode(_) ⇒ Object

Defines the underlying format used during traces or services encoding. This method must be implemented and should only be used by the internal functions.

Raises:

  • (NotImplementedError)


26
27
28
# File 'lib/ddtrace/encoding.rb', line 26

def encode(_)
  raise NotImplementedError
end

#encode_traces(traces) ⇒ Object

Encodes a list of traces, expecting a list of items where each items is a list of spans. Before dump the string in a serialized format all traces are normalized. The traces nesting is not changed.



16
17
18
19
20
21
22
# File 'lib/ddtrace/encoding.rb', line 16

def encode_traces(traces)
  to_send = []
  traces.each do |trace|
    to_send << trace.map(&:to_hash)
  end
  encode(to_send)
end