Tracing

Cadenza adds W3C trace context information (trace-id, parent-Id and span-id) to any related log and the outgoing http requests.

HTTP Requests

Incoming Requests

Information from the incoming request is used. If a traceparent header is present, the trace-id and parent-id are extracted. Otherwise, a trace-id and parent-id are generated.

The tracestate header property is ignored.

Outgoing Requests

If an outgoing HTTP request is triggered by an incoming request, the trace ID and a newly generated span ID are added to the traceparent header. The version is always set to 00, and the sample flag is always set to "true".

The ‘tracestate’ header property is not set.

Logging

Parameter Description

traceId

ID of a bundled set of queries or requests, used to uniquely identify a distributed trace across multiple programs.

spanId

ID of the span for the currently running query or request

parentSpanId

ID of the parent span of the current span

spanStartTime

Start time of the current span, as ISO-8601 string

spanEndTime

End time of the current span, as ISO-8601 string

Cadenza sets the W3C trace context information (traceId, parentSpanId and spanId) to the MDC. This enables information to be included in every log entry created during a request.

To enable logging of trace information, the system property "log4j2.isThreadContextMapInheritable" must be set to "true", see Environment Variables, System Properties and Other Runtime Configuration Options.

The system property is already enabled in our distribution and Docker images.

Span start and end events can be logged by setting the CADENZA_LOGLEVEL_REQUEST_TRACING system property to INFO.

Syslog Appender

The appender will automatically log all MDC values when the default file “EcsLayout.json” is used.

Console and File Appender

The layout pattern requires the following entries and can be overwritten with the system property CADENZA_LOGGING_PATTERN_LAYOUT

...  %mdc{traceId} %mdc{parentSpanId} %mdc{spanId}  %mdc{spanStartTime}  %mdc{spanEndTime} ...