Skip to content

TraceWhen

TraceWhen is a table rule that enables per-record verbose logging when a source field matches a list of values. It is the targeted-debugging tool of choice when one specific row, or a small set of rows, behaves differently from the rest.

Usage

Add TraceWhen to a CDM table's Comments field with logic::

logic: TraceWhen(:patient_id, ["abc-123", "def-456"])

The first argument is the source field to match against; the second is a list of values that activate tracing. When any source row has a matching value, every rule that runs for that row writes a detailed trace line to the per-table log.

What gets logged

Each rule's name and inputs/outputs are logged for the matched rows. Rule names are demangled, so the log shows the DSL name (e.g. UsagiMap) rather than the C++ symbol (_ZN8UsagiMap...).

Performance impact

Tracing has a per-row cost only for rows that match. Non-matching rows go through the normal fast path. It is safe to leave a TraceWhen rule in place during a long run as long as the value list is small.

Limitations

Tracing is automatically disabled inside recursive additionalQueue mapping calls, to prevent re-entrant logging from corrupting the trace output. This is intentional — if you need to trace inside one of those calls, restructure the chain so the tracing happens at the outer scope.