-
Notifications
You must be signed in to change notification settings - Fork 378
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 GC metrics collection without native(C++) modules #274
Conversation
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.
Cool. @SimenB and @siimon might have some thoughts on aligning these metrics with node-prometheus-gc-stats. I like that this uses a summary for the pause duration instead of a counter, but I wonder if the two counter names should end with _total
to match that module. That would cause trampling if both modules are used -- prom-client could detect if node-prometheus-gc-stats is loaded and not collect GC metrics itself maybe. (thinking out loud, not sure if these are good ideas or not.)
Tested locally, looks good. Have a CI failure though. I know SimenB will also ask for the changelog to be updated 🙂
@zbjornson I've fixed unit tests. Regarding naming of metrics I do not have strong opinion. On the other side this metrics is not drop in replacement for node-prometheus-gc-stats . As I said some metrics is available only at node-prometheus-gc-stats (and this information is not available through perf_hooks interface). So there might be a reason to have both sets of metrics available at the same time. If we will use same names for metrics - than prom-client will be conflicting with node-prometheus-gc-stats module. |
@SimenB what can I do to get this PR merged ? |
@zbjornson sorry for disturbing you, but how can I have this PR merged ? |
8c503fc
to
99f65d3
Compare
I’m not a huge fan of adding checks in prom-client for detecting other libraries, in this case gc-stats. If we could go around it with different naming that would be great. I’ve not read up on the native gc stats api, but what is preferred between this and the “old” solution? When should you use this and not the other? Should there be some guidance in the docs on this? |
d6f2cf6
to
29b6d86
Compare
Re-reviewing... sorry for letting this sit. The (FWIW, the GC duration reported by perf_hooks and gc-stats is very similar.) That means the current benefit of this PR is no native add-on for users to deal with and duration reported as a Summary (see also issue in node-prometheus-gc-stats to convert to a histogram), but the downside is no bytes_reclaimed metric. One possible route forward is to essentially move node-prometheus-gc-stats into this module: add a note in the readme like "GC duration is available as a default metric. If you also desire the number of bytes reclaimed by each collection, you can install TBD is the |
Now that I think about it, I think this method of determining bytes reclaimed is not accurate because v8's GC is concurrent. I've asked hooraybuffer on Twitter to confirm. Given that, I think this perf_hooks impl is the best route forward. |
@zbjornson thank you for spending your time on this PR and research you have made regarding "bytes reclaimed" metric. |
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.
I'm in favour of allowing useful node.js builtin metrics to be exposed, and gc times are useful. Long gc times are a signal of ill health of a service. I don't think the names should be the same as the gc stats, I think they should be different (for coexistence and transition), and should be prom standard. These names should be run through the promcheck tool. If a histogram was used there wouldn't be a need for seperate count and summary metrics. Is there a reason to not use a prom histogram?
I see it as a great fit to deprecate the gc-stats module if it could be added into prom-client with no third party dependencies! Sorry for taking so long on this, will try and keep an eye on this! @yvasiyarov if you could make the requested changes @sam-github pointed out that would be great and after that I think we can merge this one. @sam-github thanks for taking your time on reviewing this! |
@siimon @sam-github thank you for the feedback. I will make requested changes in a few days |
Make metric names compatible with promtool check
@siimon @SimenB @zbjornson @sam-github guys, please, have a look at updated PR |
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.
Looks pretty good. Sorry if I'm bikeshedding the details, its just that once its published its hard to change the details without being semver-major.
@sam-github thank you for your feedback, I really appreciate that. Please have another look at PR |
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.
I made two small suggestions, but this LGTM. Dependency on c++ addons is a continual source of pain for users, I think this is going to be really helpful.
Sorry, one other suggestion. The docs that got added to the CHANGELOG.md, I think they should go in the README.md, and the CHANGELOG.md should just have a oneliner: Add: |
Co-Authored-By: Sam Roberts <vieuxtech@gmail.com>
Co-Authored-By: Sam Roberts <vieuxtech@gmail.com>
@sam-github I've updated both CHANGELOG.md and README.md |
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
🎉👍 |
Will try and merge some more PRs and make a release when I’m back on a regular computer on Monday 👍 |
When will this pull request be released ? I need gc metrics in my project. Many thanks ! |
After #333 lands |
I've implemented GC monitoring using perf_hooks builtin module (no dependencies on third party native modules).
Unfortunately perf_hooks module does not provide ability to measure heap size before GC, so I do not report amount of garbage collected( like https://github.com/SimenB/node-prometheus-gc-stats does)
But this implementation reports GC duration percentiles(with split by GC type) which can be quite useful.