07-23-2019 03:51 AM
Hello everybody,
I want to create some metrics related to API call time.
For now, I am trying to subtract date.now and pipe.startTime using following expression (Math.trunc((Date.now() - pipe.startTime)) ) in mapper preceded by REST POST. Sceleton of pipeline attached.
The issue is this solution not quite accurate. I’ve tried to compare the time that I received by expression and time for snaplogic log and they are different.
Does any body have an idea how to retrieve the correct time in mapper using some expression?
Appreciated for any help.
07-23-2019 08:27 PM
If I were you, I would add a mapper before the REST POST, which adds a Date.now() field, and then after the execution pick up that value from the $original output from the POST, and subtract the value of another Date.now(). You should now have the length of time between the two.
07-24-2019 04:07 AM
Great tip. Thank you. It will works for me
08-13-2019 03:16 AM
The solution works fine only in case if in Execute task option Reuse executions to process documents set to false. I found strange behavior when the option set to true. Based on log every API call takes less that one second, but I observe in metric data value that exceed 80 sec ( which is impossible according timeout of API service which is 30 second)
08-21-2019 03:06 AM
Finally I found the solution. The solution is instead of mapper I used script component to set up start date. After that deduction was performed in mapper component.