Skip to content

Commit e97a9cf

Browse files
authored
Merge pull request #22 from 4n4nd/v0.0.2
Add properties `start_time` and `end_time` (datetime objects)
2 parents 25e5b7c + 18f73a9 commit e97a9cf

File tree

3 files changed

+14
-2
lines changed

3 files changed

+14
-2
lines changed

prometheus_api_client/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
""" A collection of tools to collect and manipulate prometheus metrics"""
22

33
__title__ = "prometheus-connect"
4-
__version__ = "0.0.2b1"
4+
__version__ = "0.0.2b3"
55

66
from .prometheus_connect import *
77
from .metric import Metric

prometheus_api_client/metric.py

+12
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,10 @@ def __init__(self, metric, oldest_data_datetime=None):
6868
)
6969
self.metric_values["ds"] = pandas.to_datetime(self.metric_values["ds"], unit="s")
7070

71+
# Set the metric start time and the metric end time
72+
self.start_time = dateparser.parse(str(self.metric_values["ds"].head(1).values[0]))
73+
self.end_time = dateparser.parse(str(self.metric_values["ds"].tail(1).values[0]))
74+
7175
def __eq__(self, other):
7276
"""
7377
overloading operator ``=``
@@ -145,6 +149,14 @@ def __add__(self, other):
145149
# truncate the df within the mask
146150
new_metric.metric_values = new_metric.metric_values.loc[mask]
147151

152+
# Update the metric start time and the metric end time for the new Metric
153+
new_metric.start_time = dateparser.parse(
154+
str(new_metric.metric_values["ds"].head(1).values[0])
155+
)
156+
new_metric.end_time = dateparser.parse(
157+
str(new_metric.metric_values["ds"].tail(1).values[0])
158+
)
159+
148160
return new_metric
149161

150162
if self.metric_name != other.metric_name:

setup.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ def get_install_requires():
1212

1313
setuptools.setup(
1414
name="prometheus-api-client",
15-
version="0.0.2b1",
15+
version="0.0.2b3",
1616
author="Anand Sanmukhani",
1717
author_email="[email protected]",
1818
description="A small python api to collect data from prometheus",

0 commit comments

Comments
 (0)