Skip to content
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

feature request: query_metric(start/end params) to support native Python datetime #43

Closed
vnugent opened this issue Mar 16, 2017 · 0 comments

Comments

@vnugent
Copy link

vnugent commented Mar 16, 2017

Python prides itself for English like/expressive syntax. Currently using Java-esque epoch time for start and end time range in query_metric(..., start=<start_timestamp>, end=<end_timestamp>) seems to a bit awkward to work with (at least in 2.7). I have to add the following code to get metrics within the last 5 minutes.

def unix_time_millis(dt):
    return '{:.0f}'.format((dt - epoch).total_seconds() * 1000)
...
now = datetime.utcnow()
end = unix_time_millis(now)
start = unix_time_millis(now - timedelta(minutes=5))
data = client.query_metric(MetricType.Counter, metric_id, start=start, end=end)

It would be nice if query_metric() can support native Python datetime, time, timedelta.

burmanm added a commit that referenced this issue Mar 28, 2017
Allow use of datetime or timedelta where approriate, fixes #43
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

No branches or pull requests

1 participant