Skip to main content

TRACE

[attrname := ] TRACE(baserecset, [ options ] );

attrnameOptional. The name for the expression.
baserecsetThe set of data records for which the TRACE is defined.
optionsOptional. One or more of the options listed below.

The TRACE expression defines tracing to log files (Thor slave logs, hThor logs, or Roxie logs).

You can add TRACE to your code at interesting junctures without any impact on performance. Later, if you need to investigate behavior, you can enable them without modifying the code by setting an option or stored BOOLEAN.

Tracing is written to log files, in the form:

TRACE: <name><fieldname>value</fieldname>...</name> 

Tracing is not output by default even if TRACE statements are present; tracing is only output when the workunit debug value traceEnabled is set or if the default platform settings are changed to always output tracing. In Roxie you can also request tracing on a deployed query by specifying traceEnabled=1 in the query XML.

It is therefore possible to leave TRACE statements in the ECL without any detectable overhead until tracing is enabled. To enable tracing:

#OPTION ('traceEnabled', 1) // trace statements enabled 

It is also possible to override the default value for KEEP at a global, per-workunit, or per-query level.

#OPTION ('traceLimit', 100) // overrides the default KEEP value (10) 

You can use a stored BOOLEAN as the filter expression for a trace activity to allow you to turn individual trace activities on and off.

TRACE Options

The following options are available for TRACE:

[filterExpression,] [KEEP(n),] [SKIP(n),] [SAMPLE(n),][NAMED(string)]

filterExpressionOptional. A valid expression which acts as a filter. Only rows matching the filter condition are included in the tracing.
KEEP(n)Optional. Specifies the number of rows to trace.
SKIP(n)Optional. Specifies the number of rows to skip before trace begins.
SAMPLE(n)Optional. Specifies that only every nth row is traced. .
NAMED(string)Optional. Specifies the name for rows in tracing.

Example:

#OPTION ('traceEnabled', TRUE); //TRACE writes to log only if TRUE
FilterValue := 4;
myRec := { STRING Name, REAL x, REAL y };
ds := DATASET([ {'Jim' , 1, 1.00039},
                {'Jane', 2, 2.07702},
                {'Emil', 3, 2.86158},
                {'John', 4, 3.87114},
                {'Jean', 5, 5.12417},
                {'Gene', 6, 6.20283} ], myRec);
myds := TRACE(ds,x>filterValue,NAMED('person')); //trace only if x > filterValue
myds;