Module: Datadog::Encoding::JSONEncoder::V2
- Extended by:
- Datadog::Encoding::JSONEncoder
- Defined in:
- lib/ddtrace/encoding.rb
Overview
New version of JSON Encoder that is API compliant.
Constant Summary collapse
- ENCODED_IDS =
[ :trace_id, :span_id, :parent_id ].freeze
Constants included from Datadog::Encoding::JSONEncoder
Class Method Summary collapse
Methods included from Datadog::Encoding::JSONEncoder
Methods included from Encoder
Class Method Details
.encode_traces(traces) ⇒ Object
59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 |
# File 'lib/ddtrace/encoding.rb', line 59 def encode_traces(traces) trace_hashes = traces.collect do |trace| # Convert each trace to hash trace.map(&:to_hash).tap do |spans| # Convert IDs to hexadecimal spans.each do |span| ENCODED_IDS.each do |id| span[id] = span[id].to_s(16) if span.key?(id) end end end end # Wrap traces & encode them encode(traces: trace_hashes) end |