@@ -21,15 +21,14 @@ class Metric:
21
21
A Class for `Metric` object
22
22
23
23
: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 \
26
26
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.
29
27
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
33
32
34
33
Example Usage:
35
34
``prom = PrometheusConnect()``
@@ -64,20 +63,19 @@ def __init__(self, metric, oldest_data_datetime=None):
64
63
65
64
def __eq__ (self , other ):
66
65
"""
67
- overloading operator `= `
66
+ overloading operator ``=` `
68
67
69
68
Check whether two metrics are the same (are the same time-series regardless of their data)
70
69
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
-
74
70
Example Usage:
75
71
``metric_1 = Metric(metric_data_1)``
76
72
77
73
``metric_2 = Metric(metric_data_2)``
78
74
79
75
``print(metric_1 == metric_2) # will print True if they belong to the same time-series``
80
76
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
81
79
"""
82
80
return bool (
83
81
(self .metric_name == other .metric_name ) and (self .label_config == other .label_config )
@@ -101,18 +99,24 @@ def __str__(self):
101
99
102
100
def __add__ (self , other ):
103
101
"""
104
- overloading operator `+`
102
+ overloading operator ``+``,
105
103
Add two metric objects for the same time-series
106
104
107
105
Example Usage:
108
- ``metric_1 = Metric(metric_data_1)``
106
+ .. code-block:: python
109
107
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
111
117
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
116
120
"""
117
121
if self == other :
118
122
new_metric = deepcopy (self )
0 commit comments