Add feature to set datetime object as value for gauge collector
Was working on project where the value of my gauge was to be a datetime. No built in features. This is simple update and has been tested in production to work well.
Thank you for the contribution! Couldn't this be done with
.set(dt.timestamp())though? I think the reason we don't have this is that is not much harder to write and keeps our interface simple with only taking floats.
When working with grafana for visuailzations they expect milliseconds rather than epoch seconds. So you have to multiply by 1000. in this case we drop decimals and make an integer. If using grafana and want to sort or visualize events the best way is to set the gauge value as the timestamp of the event.
I understand a case against merging if it can be confusing. However it will be useful for some people.