Open tback opened 6 years ago
It'd be great to know if this has a chance of getting accepted when it's done.
Would you mind adding a link to the post that describes the usage pattern you outlined above?
I read the blog post you mentioned. I would rather not add it. If you need to do it, it should be possible to do it on your own. In the example from the blog post a Java static initializer is used, which makes sure the code only runs once. I don't think we should fix the shortcomings of PHP within this library. It's more of a pattern than a feature.
PHP doesn't provide a method to share data between requests out of the box. prometheus_client_php
solves this shortcoming with storage adapters. Initializing metrics with 0 is a common usage pattern for prometheus and needs to share data between requests. Why is one inside the scope of this library, but the other one is not?
This code is a work in progress. I'm opening the pull request this early to learn if you'd accept this when it's done?
Prometheus Authors (Brian) recommend to create zero value for metrics known to exist in the future.
The usage pattern I want to enable is this:
Initialization is valid as for as long as the data exists in the storage adapter.