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



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

def content_type
  CONTENT_TYPE
end

.encode(obj) ⇒ Object



60
61
62
# File 'lib/ddtrace/encoding.rb', line 60

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

.join(encoded_data) ⇒ Object



64
65
66
67
68
69
# File 'lib/ddtrace/encoding.rb', line 64

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

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