Module: Datadog::Encoding::MsgpackEncoder

Extended by:
Encoder
Defined in:
lib/ddtrace/encoding.rb

Overview

Encoder for the Msgpack format

Constant Summary collapse

CONTENT_TYPE =
'application/msgpack'.freeze

Class Method Summary collapse

Class Method Details

.content_typeObject



53
54
55
# File 'lib/ddtrace/encoding.rb', line 53

def content_type
  CONTENT_TYPE
end

.encode(obj) ⇒ Object



57
58
59
# File 'lib/ddtrace/encoding.rb', line 57

def encode(obj)
  MessagePack.pack(obj)
end

.join(encoded_data) ⇒ Object



61
62
63
64
65
66
# File 'lib/ddtrace/encoding.rb', line 61

def join(encoded_data)
  packer = MessagePack::Packer.new
  packer.write_array_header(encoded_data.size)

  (packer.buffer.to_a + encoded_data).join
end