-
Notifications
You must be signed in to change notification settings - Fork 376
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
feat: implement advanced event loop monitoring #278
Conversation
@SimenB can you please have a look at this pool request ? |
ba98ee5
to
0e447ec
Compare
I'm +1 on this. This PR has commits from your other PRs; I didn't look closely to see if this really depends on the other commits, but the last commit looks like it's the only relevant one. Can you update the changelog please? (It's also worth mentioning in the changelog that this makes the existing event loop lag metric obey the Sorry for the slow reviews! |
Actually, per #177, it sounds like we shouldn't be doing this in any of the stock metrics. |
d6f2cf6
to
29b6d86
Compare
Could you rebase this so it doesn't have #274 included? That would allow it to be more easily reviewed. I took a look, but I'm confused. I thought I'd see calls to https://nodejs.org/api/perf_hooks.html#perf_hooks_perf_hooks_monitoreventloopdelay_options |
#274 has been merged now, so this really needs a rebase 🙂 |
0e447ec
to
15c22e1
Compare
15c22e1
to
00f0fde
Compare
@SimenB I've updated PR, please, have a look |
@sam-github I'm sorry for mixing up several PR's in one branch. There was no response to this PR for a while so I thought it was abandoned and reused this branch in one of my projects. I've cleaned up the branch and removed everything except event loop monitoring. |
Thanks @yvasiyarov -- just to let you all know, there's a Node.js sec release imminent, it'll be a couple days before I'm free to look at prom-client again. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A couple quick suggestions. Also, I wonder if given how different these metrics are, if the new ones can be called by the same name node, their source, calls them "event loop delay" (not lag)?
I think it would be helpful if the README somewhere pointed to the node docs and said that's what the events are (so people can go look there to see what they mean).
Its really unfortunate that these have to be gauges, but that has to be fixed upstream in node. Its on my TODO list, but not at the top :-(/.
I looked more closely, this will only report I don't know, perhaps it should either always report lag, calculated the old way? Or perhaps, on 10.x it reports lag the old way but not the others, and on 12+ it reports the event loop delay mean as the Or perhaps it doesn't matter, people don't expect metrics to be consistent across node.js major bumps? |
Co-Authored-By: Sam Roberts <[email protected]>
Co-Authored-By: Sam Roberts <[email protected]>
Co-Authored-By: Sam Roberts <[email protected]>
My intention was to keep reporting |
I think it's definitely worth to mention in README that If we name metrics differently - then we should explain what is the difference between https://github.com/nodejs/node/blob/743c28104f3db504963409e8e91700e430131221/src/node_perf.cc#L508 and https://github.com/yvasiyarov/prom-client/blob/73083f542c3f4b78a3c7121c5378b289ccdf5a4d/lib/metrics/eventLoopLag.js#L22 . For many people "lag" and "delay" are synonymous, so we can not explain the difference between two implementations by using different names.
The general event loop description available here - https://nodejs.org/uk/docs/guides/event-loop-timers-and-nexttick/. But it does not has that much technical details. Which one would you prefer ?
I can pass every measurement of event loop delay to JS word by using perf_hooks API. |
Yes, but they chose to summarize, rather than just count into buckets (like a prom-style historgram). I think per_hooks should allow the user of the API to supply buckets, and for the measured values to be simply counted into the buckets. This would allow prom-client to take it's bucket config, and basically pass it into Node.js C++-land where the counting would occur. That the api is notfication based rather than scraped is probably not such a big deal, accumulation could occur in prom-client. I don't see that change as being more costly in C++, at least not obviously, it just replaces a bunch of math to calculate the percentiles with simple bucker level comparisons and increment of counters. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. I think you can make a more specific file-global eslint ignore, its more global, but its also clear what's being ignored. I wasn't sure if it was some style rule that you disagreed with, once I backed out the eslint I saw what it was. For the record, eslint hates perf_hooks:
error The 'perf_hooks.monitorEventLoopDelay' is not supported until Node.js 11.10.0. The configured version range is '>=10' node/no-unsupported-features/node-builtins
Co-Authored-By: Sam Roberts <[email protected]>
Co-Authored-By: Sam Roberts <[email protected]>
Co-Authored-By: Sam Roberts <[email protected]>
Thank you, @sam-github ! |
@yvasiyarov nodejs/node#32018 (FYI) Node.js default behaviour is changing, for the better IMO. |
Guys, I'm sorry for bothering you with one more pull request :-)
I've implemented more advanced event loop monitoring based on functionality provided by Node11.
perf_hooks.monitorEventLoopDelay() use libuv timer, so its measurements are more precise.