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). - encode_
payload_ from_ v1 - V1-native analog of
encode_payload. Downgrades v1’s unified attribute model back to the samemeta/metrics/meta_struct-shaped wire fields, so the emitted JSON body is equivalent to what a v0.4 tracer would produce for the same trace — see [crate::msgpack_encoder::v04::span_v1] for the mapping table this mirrors. Chunk-level context (trace_id,origin,priority,sampling_mechanism,dropped_trace, chunk attributes) is propagated into every span, matching thev1::TraceChunk-level granularity v1 operates at.