@@ -21,15 +21,14 @@ class Metric:
2121 A Class for `Metric` object
2222
2323 :param metric: (dict) A metric item from the list of metrics received from prometheus
24- :param oldest_data_datetime: (str) So any metric values in the dataframe that are older than
25- this value will be deleted when new data is added to the dataframe using
24+ :param oldest_data_datetime: (str) Any metric values in the dataframe that are older than \
25+ this value will be deleted when new data is added to the dataframe using \
2626 the __add__("+") operator.
27- Example: oldest_data_datetime="10d", will delete the metric data that is older
28- than 10 days. The dataframe is pruned only when new data is added to it.
2927
30- oldest_data_datetime="23 May 2019 12:00:00"
31-
32- oldest_data_datetime="1561475156" can be set using the unix timestamp
28+ * `oldest_data_datetime="10d"`, will delete the metric data that is older \
29+ than 10 days. The dataframe is pruned only when new data is added to it. \n
30+ * `oldest_data_datetime="23 May 2019 12:00:00"`\n
31+ * `oldest_data_datetime="1561475156"` can also be set using the unix timestamp
3332
3433 Example Usage:
3534 ``prom = PrometheusConnect()``
@@ -64,20 +63,19 @@ def __init__(self, metric, oldest_data_datetime=None):
6463
6564 def __eq__ (self , other ):
6665 """
67- overloading operator `= `
66+ overloading operator ``=` `
6867
6968 Check whether two metrics are the same (are the same time-series regardless of their data)
7069
71- :return: (bool) If two Metric objects belong to the same time-series,
72- i.e. same name and label config, it will return True, else False
73-
7470 Example Usage:
7571 ``metric_1 = Metric(metric_data_1)``
7672
7773 ``metric_2 = Metric(metric_data_2)``
7874
7975 ``print(metric_1 == metric_2) # will print True if they belong to the same time-series``
8076
77+ :return: (bool) If two Metric objects belong to the same time-series,
78+ i.e. same name and label config, it will return True, else False
8179 """
8280 return bool (
8381 (self .metric_name == other .metric_name ) and (self .label_config == other .label_config )
@@ -101,18 +99,24 @@ def __str__(self):
10199
102100 def __add__ (self , other ):
103101 """
104- overloading operator `+`
102+ overloading operator ``+``,
105103 Add two metric objects for the same time-series
106104
107105 Example Usage:
108- ``metric_1 = Metric(metric_data_1)``
106+ .. code-block:: python
109107
110- ``metric_2 = Metric(metric_data_2)``
108+ metric_1 = Metric(metric_data_1)
109+ metric_2 = Metric(metric_data_2)
110+ metric_12 = metric_1 + metric_2 # will add the data in ``metric_2`` to ``metric_1``
111+ # so if any other parameters are set in ``metric_1``
112+ # will also be set in ``metric_12``
113+ # (like ``oldest_data_datetime``)
114+
115+ :return: (`Metric`) Returns a `Metric` object with the combined metric data \
116+ of the two added metrics
111117
112- ``metric_12 = metric_1 + metric_2`` # will add the data in metric_2 to metric_1
113- # so if any other parameters are set in metric_1
114- # will also be set in metric_12
115- # (like `oldest_data_datetime`)
118+ :raises: (TypeError) Raises an exception when two metrics being added are \
119+ from different metric time-series
116120 """
117121 if self == other :
118122 new_metric = deepcopy (self )
0 commit comments