Description
Is your feature request related to a problem? Please describe.
Although analytics aren't supported, it would be nice if we could track "inefficient" cloud functions and triggers, which could be displayed in the dashboard with a message on how to 🚀 functions and maximise efficiency.
Describe the solution you'd like
It would be nice if we could specify a "timeout" value (e.g 5000), so if a function runs for longer than this, it's recorded as a slow function to be optimised, and a timeout is returned to the client from the server.
It might also help to have some sort of timing trace to be provided to help work out where the bottleneck is happening, so we can easier isolate whether performance issues are Parse Server decoding / encoding etc related, or cloud code.
Describe alternatives you've considered
Manually coding into cloud functions
I've worked on a conceptual PR, that tracks the timings of function called, function decoding, cloud validator, cloud function, and response encoding times. It's not ready for merging yet, more of a concept to help understand the idea around this FR. Here is the link.. This could easily be extended to triggers as well.
Here's what a slow function looks like:
{
params: {},
error: { message: 'Script timed out.', code: 141 },
events: [
{ name: '(Parse) function called', time: 0 },
{ name: '(Parse) function decoding', time: 0 },
{ name: 'cloud validator', time: 0 },
{ name: 'cloud function', time: 4794 },
{ name: '(Parse) response encoding', time: 0 }
],
context: {},
functionName: 'cloudFunction',
timeTaken: 4794.519228000194,
master: false,
}
In this example, a cloud function takes nearly 5s to complete, with a Parse Server timeout of 3s (slowTracking.timeout: 3000). Judging by "events", the bottleneck is all coming from the developers' cloud function.