-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Ability to override Created Timestamp on new metric or vector instance. #1364
Comments
Oh, nice use case, that didn't cross my mind. I think it is important to not allow overriding the Now function in Without looking at how implementation would look like, I like the |
Moving discussion from slack to this issue @ArthurSens: @ArthurSens: @bwplotka: @bwplotka: @bwplotka: @bwplotka: @bwplotka: @ArthurSens: |
What documentation do we need to make clearer about NewConstMetricWithCreatedTimestamp? |
I would say we should put some created timestamp primer on our readme? |
Maybe a test example so it shows up in godocs? |
Currently
NewCounter
(and similar for other metrics with created timestamp) andCounterVec.With..
family use time.Now() to obtain created timestamp.This will work in majority of cases, but it will be a problem for exporters which might want to use those "normal" metrics (as opposed to collectors with e.g. const metrics) to report values they don't control (e.g cadvisor showing Linux counters). The counters they might expose can be started back in time, so created timestamp can't be "now" in the moment of exporter creating that metric.
We have to figure out API that would allow us to override time.Now() logic. This problem is a little bit related to #1354 but for production use case of modifying created timestamp. Some yolo ideas (didn't think about this through):
NewConstMetricWithCreatedTimestamp
. Alternatively ask in those cases to reset metric to 0 - both kind of bad UX.CreatedTimestampFunc
(prone to so many issues) or simplyCreatedTimestamp time.Time
. The latter is nice, but won't work with Vec easily 🤔WithLabelValues...CT
(and 3 others) that will allow specifying labels/label values and time.Time Created timestamp.Acceptance Criteria:
Counter
as scrape can happen anytime between registration and `SetCreatedTimestamp).cc @beorn7 @ArthurSens
The text was updated successfully, but these errors were encountered: