Expand description
Agentless APM JSON encoder.
Encodes Datadog v04 trace chunks to the JSON body
accepted by the Datadog HTTP trace intake (POST /v1/input).
§Differences from the regular agent (msgpack v04) encoding
- Wire format: JSON, wrapped as
{"traces": [ {hostname, env, ..., spans: [...] }, ... ]}. Per-trace metadata (hostname, env, language*, tracerVersion, runtimeID, containerID) is inlined on each trace instead of being carried in request headers. Hostname is always emitted - IDs:
trace_id,span_id,parent_idare lowercase hex strings (16 chars; 32 for span-link trace IDs) - 128-bit trace IDs: only the low 64 bits go into
trace_id; the_dd.p.tidmeta tag carries upper 64 bits - Span links / events: not top-level fields. They are JSON-stringified into
meta["_dd.span_links"]andmeta["events"], each truncated to 25_000 chars. No top-levellinksfield is emitted. If meta attributes for “_dd.span_links” of “events” are already attached to the span we will keep existing fields and the span level field will be dropped - Stats / top-level flags: the intake has no trace-agent to compute them, so the encoder
injects
meta["_dd.compute_stats"]="1"on the first span of each chunk andmetrics["_trace_root"]=1where applicable. - Non-finite metrics (NaN/Inf) are dropped (JSON can’t represent them).
TODO: span normalization (service/name/resource/type truncation + defaults)
Functions§
- encode_
payload - Encode the given
tracesto the agentless JSON payload (/v1/inputbody).