Clever TaglineC
Convex Community16mo ago
11 replies
Clever Tagline

Tracking time of an API call

I'd like to track the execution time of an API call made in an action, and save the duration into a field. This call could take anywhere from a couple seconds to well over a minute. I'm already creating a record at the start of the action right before calling the API, so my first thought was to just get a new
Date
instance (or using Date.now()), and then compare the value against the record's creation time. However, then I read this about dates in Convex functions:

https://docs.convex.dev/functions/runtimes#using-randomness-and-time-in-queries-and-mutations

Is there another way to pull this off and accurately track when I receive the response from the API call?
Convex functions can run in two runtimes:
Runtimes | Convex Developer Hub
Was this page helpful?