-
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
Add the officially recommended metrics #25
Conversation
Interesting, thanks! I'm away for this week and half of next so won't have a chance to dive into the code. But all of your suggestions seems reasonable and should be implemented! A few other thoughts,
Did my thoughts make any sense? |
One last things; at work we have our own wrapper around this library adding a few more metrics (event loop lag, OS load, process handles and process requests), that are all something node exposes. Would you be interested in adding those as well? |
actually, when thinking about this point 1 and 3 are pretty much the same thing. Would it make any sense to add a configuration object into the metrics function where you can disable/enable what metrics you want? Then it's just a matter of selecting sensible defaults. I like your ideas, we do the same thing. I don't see any downside to this, as long as we have a good api where it's easy to enable and disable any of them. Just keep in mind that I'm trying to keep the number of dependencies as low as possible! |
There is no "start measuring" right now, so disabling them can't be done until you first query for them, and that'd mean keeping some state around. So I still prefer having a "start polling default metrics", and this function can take options disabling them or not. All of those extras are dependency free, just using node's own APIs 😄 I'm back at work now, so I'll spend some time on it. |
True, sounds great! :) |
I opened a PR with Prometheus to document this a bit better btw. If you have some comments, that'd be appreciated! |
@siimon This is ready to go now 😄 |
It's a bit hard to get the tests to pass when it depends on both node version and os. Ideas? |
@siimon Latest commit makes it pass, but I'm not happy with it... Ideas? |
I dug into GC, and it got pulled from Node here: nodejs/node#174 And open issue about adding same sort of data back is here: nodejs/node#4496 And this userland module seems to fit the bill. I can create a project exposing this along with registering it with prom-client, which can be linked in the readme here? |
A couple of ideas,
|
|
I'll try to wrap up the tests at work tomorrow, but I came over prometheus/docs#506, and it touches upon the fact that default metrics should be registered by default, but able to be turned off. Thoughts on that? IDK if it'd be considered a breaking change, but it's just a number anyways 😄 |
Yeah, the best thing would be if users of this lib doesn't have to do anything, and as you said I think we should do a major bump so we don't introduce any weird duplicate metrics for those who are doing this by themselves. |
Thanks for working on this! I am planning to make use of it as soon as it lands. I agree these metrics should be enabled by default, and agree that that's consistent with the Prometheus docs. |
@siimon Should be good to go now. I suggest removing the lower case exports ( |
value: 'my-bogus-platform' | ||
}); | ||
|
||
if(cpuUsage) { |
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.
Have to support both node@<6.1
and node@>=6.1
I think |
I did them as they are because of the description in the original word document: https://docs.google.com/document/d/1Q0MXWdwp1mdXCzNRak6bW5LLVylVRXhdi7_21Sg15xQ/edit |
The word document says:
But in
If I run a
Or ~9MB. From the REPL itself I get:
Not sure why Node thinks it has more heap than ps does. It could be a distinction between resident size and non-resident. At any rate, I don't have strong opinions here. I'm happy to proceed with what you've got implemented for |
Ok, thanks for the analysis 😄 Should be GTG then, shouldn't be any problem to iterate on this later if we figure out we've done it wrong |
Great :) One thing we talked about earlier was enabling this by default, if I understood you correctly, the prom docs mentioned they should be enabled by default? If that is the case, my suggestion is to enable them right away, and then instead have an exported function that stops collecting if you want to do that in your service. I won't have any problems having it like that if we make a major release which I think we should |
It does collect automatically as soon as you require And I agree it should be major bump. |
Bah, thanks, i'll do a test spin and stop writing dump comments then :) |
I've no further comments, @jsha do you have any input before merging? |
LGTM |
Hi there!
All Prometheus clients are recommended to export some basic metrics https://prometheus.io/docs/instrumenting/writing_clientlibs/#standard-and-runtime-collectors.
Descriptions stolen from the official Go client, https://github.com/prometheus/client_golang/blob/master/prometheus/process_collector.go.
This PR adds all of them, although most will only work on Linux.
No tests added in case you're not interested in the addition.
Example file for testing:
Example Dockerfile for testing
Example output of running app:
Could probably add some metrics regarding stuff like GC etc.
EDIT: In hindsight, I can see that I should just check
process.platform
forlinux
instead of try-catching... I'll make that change tomorrow along with GC metrics!EDIT2: Here is the table with recommended metrics:
process_cpu_seconds_total
process_open_fds
process_max_fds
process_virtual_memory_bytes
process_resident_memory_bytes
process_heap_bytes
process_start_time_seconds