-
Notifications
You must be signed in to change notification settings - Fork 375
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
defaultMetrics should be collected synchronously #180
Comments
I didn't know about that, thanks for pointing it out! Changing should be easy enough, we just have to either make I have no preference to either solution, it'll be pretty breaking no matter what (as we expose methods to tweak the interval, which will have to be removed) |
Could the synchronous approach not be an addition (backwards compatibility), with being able to disable the background polling? |
Why would it be a breaking change? Sure the response will be different for each time you make a request but I find it hard to classify that as a breaking change. If it is a breaking change I still think it should just be implemented and not get unnecessary technical debt. |
It looks pretty breaking to me. Typical use looks like:
If Some options I can think of, all of which have downsides:
(.collect could be called .metrics and be sync or async depending on whether it receives a cb) I'm not sure how accepting of a semver-major you all are. Making |
I'm in favor of #2 also. Rather only provide one API and have it be the Right Way. 🚀 I think this "pull" interface cascades all the way down. I haven't looked exactly, but I was envisioning that all of the metric types have some new method like |
So, did a bit of poking around
That seems pretty reasonable on the face of it.... but prom-client calls https://nodejs.org/api/process.html#process_process_memoryusage on non-linux, which calls https://github.com/nodejs/node/blob/d65e6a50176e4847738a77c3579fe52c2735fd8b/deps/uv/src/unix/linux-core.c#L506-L525 ... which is sync. Maybe a one-shot sync call to read /proc isn't such a big deal? Its basically a memory read, the data is coming from kernel memory, its not going to trigger pulling data in from a spinning disk, or craziness like that. |
@sam-github you have way more knowledge about node core than I, so if you think it's fine let's go for it! |
* chore: remove support for node < 10.x * chore: simplify mem usage try/catch * fix: make example/server use PORT * chore: add async notes to loop lag metric * fix: sync collection of linux vm metrics This allows the metrics to be collected at scrape time, rather than on an interval timer. * fix: remove timestamp support * fix: sync collection of linux max fd limits * fix: sync collection of linux fd count * fix: always set start time * fix: always set version labels * fix: collect metrics on scrape, not timeout Only the event loop "lag" is still async, see the in-src notes. Fixes: #180
As noted in https://prometheus.io/docs/instrumenting/writing_exporters/#scheduling collection should be synchronous with a scrape, and not get updated in a background thread. The defaultMetrics should be called at a scrape, not with a setInterval.
The text was updated successfully, but these errors were encountered: