Skip to main content

Module json_log_encoder

Module json_log_encoder 

Source
Expand description

JSON “log exporter” trace encoder.

Emits traces in the newline-delimited JSON format consumed by the Datadog Forwarder Lambda (the legacy serverless path used when no Datadog Agent / Lambda Extension is reachable). Each emitted line is a self-contained JSON document of the form:

{"traces":[[ {span}, {span}, ... ]]}\n

Spans are greedily packed into size-bounded lines. A single span that alone exceeds the line cap is dropped (and counted in EncodeStats::spans_dropped) rather than emitted as a truncated, unparseable line.

See the cross-language specification for the wire contract and the Forwarder’s is_trace detection requirements.

Structs§

EncodeStats
Statistics reported by encode_traces.

Functions§

encode_traces
Encodes traces into newline-delimited JSON “log exporter” lines, writing them to out.
encode_traces_v1
Encodes a v1 TracerPayload into newline-delimited JSON “log exporter” lines, writing them to out. Same framing, packing, and oversized-span dropping behavior as encode_traces — see its docs — but takes v1 TracerPayload/crate::span::v1::Span input and downgrades each span’s unified attribute model back to the meta/metrics-shaped wire span via [span_v1::LogSpanV1], since the JSON log wire contract (consumed by the Datadog Forwarder Lambda) is unchanged by the v1 migration. Payload-level env/app_version/ attributes are propagated into every span (lowest precedence, below chunk and span level) — same convention as the msgpack v0.4 downgrade encoder’s encode_payload_from_v1.