Skip to content

Use realistic timer for Gauge.set_to_current_time - #109

Merged
brian-brazil merged 1 commit into
prometheus:masterfrom
hynek:master
Oct 17, 2016
Merged

brian-brazil merged 1 commit into
prometheus:masterfrom
hynek:master

Conversation

@hynek

@hynek hynek commented Oct 17, 2016

Copy link
Copy Markdown
Contributor

set_to_current_time is expected to set the value to a realistic time.
Performance counters are monotonic but don't say anything about the actual
time.

set_to_current_time is expected to set the value to a realistic time.
Performance counters are monotonic but don't say anything about the actual
time.
@brian-brazil

Copy link
Copy Markdown
Contributor

My reading of the docs is that this is wall time.

@hynek

hynek commented Oct 17, 2016

Copy link
Copy Markdown
Contributor Author

What exactly? You docs say that it sets to current unix time which I thought to be epoch time. However:

>>> from timeit import default_timer
>>> from time import time
>>> from datetime import datetime
>>> datetime.fromtimestamp(default_timer())
datetime.datetime(1970, 1, 5, 19, 25, 4, 943824)

>>> datetime.fromtimestamp(time())
datetime.datetime(2016, 10, 17, 19, 50, 9, 261461)

This seems rather useless to me and a pretty bad regression IMHO (got a lot of time()-metric > X alerts :)).

@hynek

hynek commented Oct 17, 2016 •

Copy link
Copy Markdown
Contributor Author

Oh i think I understand now; you’ve been referring to legacy (2.7) docs. default_timer is time.perf_counter() as of Python 3.3: https://docs.python.org/3.5/library/timeit.html#timeit.default_timer

(and I thought that was kind of the point of the change?)

@brian-brazil
brian-brazil merged commit 9cf0214 into prometheus:master Oct 17, 2016
@brian-brazil

Copy link
Copy Markdown
Contributor

Thanks!

@hynek

hynek commented Oct 18, 2016

Copy link
Copy Markdown
Contributor Author

It would be really cool if you could push a quick new release, since this is a nasty regression on Python 3.3+ and will probably also confuse new users.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants