$trace
$trace(value?, label, projection?) -> value<x-sx?:x>If value is omitted, the current context value is used.
Source: FUME
Documentation
Emits a trace diagnostic entry and returns the original value unchanged.
Use $trace() when you want to inspect a value without changing the result flow. This helper belongs to Diagnostics And Errors: it traces execution, but it does not stop evaluation.
The second argument is the trace label. FUME stringifies that label and stores a diagnostic entry with code F5600, the current executionId, the original value, and a rendered message in the form label: projection. If you omit the optional third argument, the traced projection is the same value that gets returned. If you provide a third argument, it changes only the diagnostic message; the function still returns the original first argument.
During verbose evaluation, trace entries are collected under diagnostics.debug. If logging is enabled for that severity, FUME also writes the rendered trace message through the configured logger's debug() method.
Examples
Emit a trace event and return the original value
This function has a side effect (emits a trace entry), but it returns the input value. The emitted trace entry is described in prose here rather than shown as fake captured logger output.
Input
This example uses the patient-summary example input. The expression reads patientId, emits a trace entry, and returns the value.
Example input
{
"patientId": "pat-0001",
"name": {
"given": "Avery",
"family": "Reed",
"display": "Avery Reed"
},
"birthDate": "1990-06-12",
"sex": "female",
"primaryCareTeam": {
"organization": "ExampleCare",
"facility": "ExampleCare Clinic",
"practitioner": {
"practitionerId": "prac-4001",
"display": "Jordan Kim"
}
},
"identifiers": {
"memberId": "mbr-3001",
"recordNumber": "rec-5001"
},
"tags": [
"demo",
"fictional"
],
"_xmlTagName": "patientSummary"
}
Expression
$trace(patientId, "patientId")
Result
"pat-0001"