-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add the possibity to track a time execution of async functions #34
Comments
Yes that is useful 😉 |
I've missed a point in this that I haven't thought before and there is only one thing to keep in mind, this will never be a 100% correct timing. Because of how underlying queueing work, There is no way around this because that how async jobs works. If we're ok with it I'm fine but we should at least warn the users! |
It's ok for me to add a warn in the docs. |
That would be the same if you timed a Promise without the utility functions want to provide (if I understand correctly). I don't think we need a warning for that. |
If your callback ends up down in the queue you would have all the overhead in timing of the others, it's something I would want to know if it can make my metrics somehow not what I expect |
A couple of thoughts:
|
The first point it's ok for me, for the second I don't understand the possible problem, can you give an example? |
Sure, imagine we have to time something like: fastify.decorate('someFn', function (arg1, arg2) {
this.log.info(arg1,arg2)
})
fastify.timeAsync(fastify.someFn, arg1, arg2) I think we would lose the |
Finally found this: https://nodejs.org/dist/latest-v16.x/docs/api/perf_hooks.html#performancetimerifyfn-options We could provide a wrapper of this in the plugin, but I think it's also pretty straightforward to use as it is. I think it's a much cleaner approach. |
I like it; we should test if this function has overheads. It uses the |
I have used it to track GC activity in the past with no perf issues, but I'll test it again for sure. |
I am removing this one from the milestone. I would prefer not blocking a new release waiting for this feature. |
What do you think of
trackAsyncCbTime
function to trace async function resolve's time?WDYT?
The text was updated successfully, but these errors were encountered: