Adding TracePoints in Groovy Jobs
There are two steps for adding TracePoints to the Groovy jobs. First, specify the API.tracepoint (variables to trace)
in your code. A TracePoint is hit every time the Groovy job processes this method, and a further trace condition is not necessary. For example, to use a month variable in a Groovy job add:
API.tracepoint (strMonth)
You can add a second (or third, etc.) variable as an additional parameter to the TracePoint in a Groovy job. API.tracepoint (variable, [variable], […])
For example,
API.tracepoint (strMonth, strYear)
You can also use several separate API calls for adding additional variables. For example:
API.tracepoint (strMonth)
API.tracepoint (strYear)
Since the trace monitor headers do not contain a variable name, additional text as a separate parameter can help identify the variable's content displayed in the trace monitor. For example:
API.tracepoint (‘variable strMonth:’ , strMonth)
API.tracepoint (‘variable strYear:’ , strYear)
API.tracepoint (‘variable strFullYear:’ , strFullYear)
Save the code, and then right-click on the Groovy job and click on Add TracePoint. You do not need to add any filters, just save the TracePoint as is. Execute the Groovy job by clicking on the Run button. In the list that shows up, in the Execution type section, right-click on the Groovy job with the word “TracePoint” in front of it. Choose Open trace monitor.
Adding API.tracepoint function in a loop
It is also possible to use multiple API.tracepoint functions in a loop.
While adding a tracepoint in a loop, it might be helpful to add a variable or text that is incremented like a counter.
When using a TracePoint in a loop, it is possible to encounter many result sets. In this case, you can use the trace filter to read the results better. For example, for the API call below where we want to trace the strProductID
variable:
API.tracepoint (strProductID, ‘variable strProductID at count’ + count)
Right-click on the Groovy job, and choose Add Tracepoint. The filter input for a TracePoint filter in a Groovy job should be the variable/column name you want to trace; in this case, strProductID.
Run the Groovy job and open the Trace monitor. In case you have multiple TracePoints, make sure you are on the right TracePoint.
When you have more than one TracePoint in a Groovy job, the column headers will be numbered. The numbers start from 0, and each number represents one TracePoint. For example, for filtering the second API call and searching for numbers 4 and 5, you can use:
Updated December 13, 2024