Skip to content
This repository was archived by the owner on May 11, 2026. It is now read-only.
This repository was archived by the owner on May 11, 2026. It is now read-only.

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

Closed

Description

@vnugent

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.

Activity

  1. added a commit that references this issue on Mar 23, 2017
    9c1044a
  2. added a commit that references this issue on Mar 28, 2017
    86dabf5
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions