DatadogTracingAppender
An io.github.smyrgeorge.log4k.Appender that publishes finished spans to a local Datadog Agent over its APM trace intake API (PUT /v0.4/traces, JSON). Register it with RootLogger.Tracing.appenders.register(...).
Spans are shipped in batches (via BatchAppender): a batch is sent as soon as it reaches batchSize spans or when batchTimeout elapses since the first span of the batch arrived — so low traffic never holds spans back for long. Within a batch, spans are grouped by trace, as the intake API expects.
The HTTP transport is a Ktor client: pass an engine explicitly, or add exactly one Ktor engine artifact for your platform (CIO, Darwin, Curl, WinHttp, Js, ...) to the runtime classpath and leave it null so the engine is discovered automatically.
The agent must have APM enabled (DD_APM_ENABLED=true); it listens on port 8126 by default.
Mapping notes:
log4k's OpenTelemetry-style hex ids are converted to Datadog's numeric ids: the low 64 bits are used, and for 128-bit trace ids the high 64 bits are preserved in the
_dd.p.tidtag. Non-hexadecimal ids (e.g. from a remote/propagated context) are hashed (FNV-1a).Finite numeric span tags become Datadog
metrics; everything else — including non-finite numbers, whichmetricscannot represent — goes tometa(stringified).Span events are encoded as a JSON array in
meta.events, mirroring the OpenTelemetry ingestion convention. An error status setserror=1pluserror.type/message/stack.
Delivery is best-effort: agent failures are reported to the console, and the batch is dropped — the appender itself keeps running.
Parameters
The Datadog service name the spans are reported under.
Base URL of the local Datadog Agent. Defaults to http://localhost:8126.
Maximum number of spans per request. Defaults to 100.
Maximum time to hold an incomplete batch. Defaults to 2 seconds.
Optional env tag applied to every span.
Optional version tag applied to every span.
Datadog span type (e.g. web, db, custom). Defaults to custom.
Optional Ktor HttpClientEngine. When null, the engine available on the classpath is used.