robotframework-prometheus 0.6.1__tar.gz → 0.8.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: robotframework-prometheus
3
- Version: 0.6.1
3
+ Version: 0.8.0
4
4
  Summary: Additional Robot Framework keywords
5
5
  Home-page: https://github.com/test-fullautomation/robotframework-prometheus
6
6
  Author: Holger Queckenstedt
@@ -22,15 +22,11 @@ Package Description
22
22
  The interface library **prometheus\_interface** provides Robot Framework
23
23
  keywords to communicate with the monitoring system **Prometheus**.
24
24
 
25
- Currently this library is under development. We work on it. But what is
26
- available up to now, is not ready for being used in productive systems
27
- (but hopefully will be in near future).
28
-
29
25
  Package Documentation
30
26
  ---------------------
31
27
 
32
- A (growing) detailed documentation of the **prometheus\_interface** can
33
- be found here:
28
+ A detailed documentation of the **prometheus\_interface** can be found
29
+ here:
34
30
 
35
31
  [PrometheusInterface.pdf](https://github.com/test-fullautomation/robotframework-prometheus/blob/develop/PrometheusInterface/PrometheusInterface.pdf)
36
32
 
@@ -19,7 +19,7 @@ import pickle, os, time, random
19
19
  import dotdict
20
20
 
21
21
  # -- import Prometheus interface
22
- from prometheus_client import start_http_server, Gauge, Counter, Info
22
+ from prometheus_client import start_http_server, Gauge, Counter, Info, Summary, Histogram
23
23
 
24
24
  # -- import Robotframework API
25
25
  from robot.api.deco import keyword, library # required when using @keyword, @library decorators
@@ -32,8 +32,8 @@ from PythonExtensionsCollection.Utils.CUtils import *
32
32
  # --------------------------------------------------------------------------------------------------------------
33
33
  # this interface library
34
34
  #
35
- LIBRARY_VERSION = "0.6.1"
36
- LIBRARY_VERSION_DATE = "17.06.2024"
35
+ LIBRARY_VERSION = "0.8.0"
36
+ LIBRARY_VERSION_DATE = "21.10.2024"
37
37
  #
38
38
  THISMODULENAME = "prometheus_interface.py"
39
39
  THISMODULE = f"{THISMODULENAME} v. {LIBRARY_VERSION} / {LIBRARY_VERSION_DATE}"
@@ -62,16 +62,18 @@ For this purpose the 'Prometheus Python client library' is used.
62
62
  self.__port_number = port_number
63
63
 
64
64
  # prometheus metric types
65
- self.__dictCounter = {}
66
- self.__dictGauges = {}
67
- self.__dictInfos = {}
65
+ self.__dictCounter = {}
66
+ self.__dictGauges = {}
67
+ self.__dictInfos = {}
68
+ self.__dictSummaries = {}
69
+ self.__dictHistograms = {}
68
70
 
69
71
  start_http_server(self.__port_number)
70
72
 
71
73
  # default info metric about this interface library
72
74
  oInfo = Info("Prometheus_interface", "Prometheus interface info")
73
75
  dictInfo = {}
74
- dictInfo['file name'] = THISMODULENAME
76
+ dictInfo['file_name'] = THISMODULENAME
75
77
  dictInfo['version'] = LIBRARY_VERSION
76
78
  dictInfo['date'] = LIBRARY_VERSION_DATE
77
79
  dictInfo['location'] = self.where_am_i()
@@ -82,6 +84,24 @@ For this purpose the 'Prometheus Python client library' is used.
82
84
  del self.__dictCounter
83
85
  del self.__dictGauges
84
86
  del self.__dictInfos
87
+ del self.__dictSummaries
88
+
89
+ # --------------------------------------------------------------------------------------------------------------
90
+
91
+ def convert_to_int_or_float(self, value):
92
+ """Little helper to convert a string value to an integer or a float
93
+ """
94
+ try:
95
+ converted_value = int(value)
96
+ return converted_value # is int
97
+ except ValueError:
98
+ pass
99
+ try:
100
+ converted_value = float(value)
101
+ return converted_value # is float
102
+ except ValueError:
103
+ pass
104
+ return None # not int and not float
85
105
 
86
106
  # --------------------------------------------------------------------------------------------------------------
87
107
  # -- library informations
@@ -121,7 +141,41 @@ For this purpose the 'Prometheus Python client library' is used.
121
141
 
122
142
  @keyword
123
143
  def add_info(self, name=None, description=None, labels=None):
124
- """add_info
144
+ """This keyword adds a new info. The content of an existing info can be defined with ``set_info``.
145
+
146
+ **Arguments:**
147
+
148
+ * ``name``
149
+
150
+ The name of the new info
151
+
152
+ / *Condition*: required / *Type*: str /
153
+
154
+ * ``description``
155
+
156
+ The description of the new info
157
+
158
+ / *Condition*: required / *Type*: str /
159
+
160
+ * ``labels``
161
+
162
+ A semicolon separated list of label names assigned to the new info
163
+
164
+ / *Condition*: optional / *Type*: str / *Default*: None /
165
+
166
+ **Returns:**
167
+
168
+ * ``success``
169
+
170
+ / *Type*: bool /
171
+
172
+ Indicates if the computation of the keyword was successful or not
173
+
174
+ * ``result``
175
+
176
+ / *Type*: str /
177
+
178
+ The result of the computation of the keyword
125
179
  """
126
180
  success = False
127
181
  result = "UNKNOWN"
@@ -155,7 +209,41 @@ For this purpose the 'Prometheus Python client library' is used.
155
209
 
156
210
  @keyword
157
211
  def set_info(self, name=None, info=None, labels=None):
158
- """set_info
212
+ """This keyword defines the content of an info. The info has to be added with '``add_info``' before.
213
+
214
+ **Arguments:**
215
+
216
+ * ``name``
217
+
218
+ The name of the info
219
+
220
+ / *Condition*: required / *Type*: str /
221
+
222
+ * ``info``
223
+
224
+ The info itself (every info is a key-value information).
225
+
226
+ / *Condition*: required / *Type*: dict /
227
+
228
+ * ``labels``
229
+
230
+ A semicolon separated list of labels assigned to the info. The order of labels must fit to the order of label names like defined in ``add_info``.
231
+
232
+ / *Condition*: optional / *Type*: str / *Default*: None /
233
+
234
+ **Returns:**
235
+
236
+ * ``success``
237
+
238
+ / *Type*: bool /
239
+
240
+ Indicates if the computation of the keyword was successful or not
241
+
242
+ * ``result``
243
+
244
+ / *Type*: str /
245
+
246
+ The result of the computation of the keyword
159
247
  """
160
248
  success = False
161
249
  result = "UNKNOWN"
@@ -207,27 +295,6 @@ For this purpose the 'Prometheus Python client library' is used.
207
295
  return success, result
208
296
 
209
297
 
210
- # TODO lighting reaktivieren (as example)
211
-
212
- # # @keyword
213
- # # def add_lighting(self):
214
- # # """add_lighting (experimental only)
215
- # # """
216
- # # self.__oLighting = Info('lighting', ': kind of lighting')
217
-
218
- # # @keyword
219
- # # def set_daylight(self):
220
- # # """set_daylight (experimental only)
221
- # # """
222
- # # self.__oLighting.info({'lighting' : 'daylight'})
223
-
224
- # # @keyword
225
- # # def set_nightlight(self):
226
- # # """set_nightlight (experimental only)
227
- # # """
228
- # # self.__oLighting.info({'lighting' : 'nightlight'})
229
-
230
-
231
298
  # --------------------------------------------------------------------------------------------------------------
232
299
  # -- prometheus metric type 'Counter'
233
300
  # --------------------------------------------------------------------------------------------------------------
@@ -693,5 +760,302 @@ For this purpose the 'Prometheus Python client library' is used.
693
760
  # eof def dec_gauge(...):
694
761
 
695
762
 
763
+ # --------------------------------------------------------------------------------------------------------------
764
+ # -- prometheus metric type 'Summary'
765
+ # --------------------------------------------------------------------------------------------------------------
766
+ #TM***
767
+
768
+ @keyword
769
+ def add_summary(self, name=None, description=None, labels=None):
770
+ """This keyword adds a new summary. The values of existing summaries can be set with ``observe_summary```.
771
+
772
+ **Arguments:**
773
+
774
+ * ``name``
775
+
776
+ The name of the new summary
777
+
778
+ / *Condition*: required / *Type*: str /
779
+
780
+ * ``description``
781
+
782
+ The description of the new summary
783
+
784
+ / *Condition*: required / *Type*: str /
785
+
786
+ * ``labels``
787
+
788
+ A semicolon separated list of label names assigned to the new summary
789
+
790
+ / *Condition*: optional / *Type*: str / *Default*: None /
791
+
792
+ **Returns:**
793
+
794
+ * ``success``
795
+
796
+ / *Type*: bool /
797
+
798
+ Indicates if the computation of the keyword was successful or not
799
+
800
+ * ``result``
801
+
802
+ / *Type*: str /
803
+
804
+ The result of the computation of the keyword
805
+ """
806
+ success = False
807
+ result = "UNKNOWN"
808
+ if name is None:
809
+ result = "Parameter 'name' not defined"
810
+ return success, result
811
+ if description is None:
812
+ result = "Parameter 'description' not defined"
813
+ return success, result
814
+ if name in self.__dictSummaries:
815
+ result = f"A summary with name '{name}' is already defined"
816
+ return success, result
817
+ oSummary = None
818
+ if labels is None:
819
+ oSummary = Summary(name, description)
820
+ else:
821
+ labellist = labels.split(';')
822
+ listLabelNames = []
823
+ for label in labellist:
824
+ label = label.strip()
825
+ listLabelNames.append(label)
826
+ oSummary = Summary(name, description, listLabelNames)
827
+ self.__dictSummaries[name] = oSummary
828
+ success = True
829
+ listResults = []
830
+ listResults.append(f"Summary '{name}' added")
831
+ if labels is not None:
832
+ listResults.append(f"with labels: '{labels}'")
833
+ result = " ".join(listResults)
834
+ return success, result
835
+ # eof def add_summary(...):
836
+
837
+ @keyword
838
+ def observe_summary(self, name=None, value=None, labels=None):
839
+ """This keyword observes a summary. The summary has to be added with '``add_summary``' before.
840
+
841
+ **Arguments:**
842
+
843
+ * ``name``
844
+
845
+ The name of the summary
846
+
847
+ / *Condition*: required / *Type*: str /
848
+
849
+ * ``value``
850
+
851
+ The value assigned to the summary.
852
+
853
+ / *Condition*: required / *Type*: int or float /
854
+
855
+ * ``labels``
856
+
857
+ A semicolon separated list of labels assigned to the summary. The order of labels must fit to the order of label names like defined in ``add_summary``.
858
+
859
+ / *Condition*: optional / *Type*: str / *Default*: None /
860
+
861
+ **Returns:**
862
+
863
+ * ``success``
864
+
865
+ / *Type*: bool /
866
+
867
+ Indicates if the computation of the keyword was successful or not
868
+
869
+ * ``result``
870
+
871
+ / *Type*: str /
872
+
873
+ The result of the computation of the keyword
874
+ """
875
+ success = False
876
+ result = "UNKNOWN"
877
+ if name is None:
878
+ result = "Parameter 'name' not defined"
879
+ return success, result
880
+ if value is None:
881
+ result = "Parameter 'value' not defined"
882
+ return success, result
883
+ value_type = type(value)
884
+ value = self.convert_to_int_or_float(value)
885
+ if value is None:
886
+ success = False
887
+ result = f"invalid type '{value_type}' of input parameter 'value'; expected int or float"
888
+ return success, result
889
+ if name not in self.__dictSummaries:
890
+ result = f"Summary '{name}' not defined"
891
+ return success, result
892
+ oSummary = self.__dictSummaries[name]
893
+ if labels is None:
894
+ oSummary.observe(value)
895
+ else:
896
+ labellist = labels.split(';')
897
+ listLabelValues = []
898
+ for label in labellist:
899
+ label = label.strip()
900
+ listLabelValues.append(label)
901
+ oSummary.labels(*listLabelValues).observe(value)
902
+ success = True
903
+ listResults = []
904
+ listResults.append(f"Summary '{name}' observed value {value}")
905
+ if labels is not None:
906
+ listResults.append(f"with labels: '{labels}'")
907
+ result = " ".join(listResults)
908
+ return success, result
909
+ # eof def observe_summary(...):
910
+
911
+
912
+ # --------------------------------------------------------------------------------------------------------------
913
+ # -- prometheus metric type 'Histogram'
914
+ # --------------------------------------------------------------------------------------------------------------
915
+ #TM***
916
+
917
+ @keyword
918
+ def add_histogram(self, name=None, description=None, labels=None):
919
+ """This keyword adds a new histogram. The values of existing histograms can be set with ``observe_histogram```.
920
+
921
+ **Arguments:**
922
+
923
+ * ``name``
924
+
925
+ The name of the new histogram
926
+
927
+ / *Condition*: required / *Type*: str /
928
+
929
+ * ``description``
930
+
931
+ The description of the new histogram
932
+
933
+ / *Condition*: required / *Type*: str /
934
+
935
+ * ``labels``
936
+
937
+ A semicolon separated list of label names assigned to the new histogram
938
+
939
+ / *Condition*: optional / *Type*: str / *Default*: None /
940
+
941
+ **Returns:**
942
+
943
+ * ``success``
944
+
945
+ / *Type*: bool /
946
+
947
+ Indicates if the computation of the keyword was successful or not
948
+
949
+ * ``result``
950
+
951
+ / *Type*: str /
952
+
953
+ The result of the computation of the keyword
954
+ """
955
+ success = False
956
+ result = "UNKNOWN"
957
+ if name is None:
958
+ result = "Parameter 'name' not defined"
959
+ return success, result
960
+ if description is None:
961
+ result = "Parameter 'description' not defined"
962
+ return success, result
963
+ if name in self.__dictHistograms:
964
+ result = f"A histogram with name '{name}' is already defined"
965
+ return success, result
966
+ oHistogram = None
967
+ if labels is None:
968
+ oHistogram = Histogram(name, description)
969
+ else:
970
+ labellist = labels.split(';')
971
+ listLabelNames = []
972
+ for label in labellist:
973
+ label = label.strip()
974
+ listLabelNames.append(label)
975
+ oHistogram = Histogram(name, description, listLabelNames)
976
+ self.__dictHistograms[name] = oHistogram
977
+ success = True
978
+ listResults = []
979
+ listResults.append(f"Summary '{name}' added")
980
+ if labels is not None:
981
+ listResults.append(f"with labels: '{labels}'")
982
+ result = " ".join(listResults)
983
+ return success, result
984
+ # eof def add_histogram(...):
985
+
986
+ @keyword
987
+ def observe_histogram(self, name=None, value=None, labels=None):
988
+ """This keyword observes a histogram. The histogram has to be added with '``add_histogram``' before.
989
+
990
+ **Arguments:**
991
+
992
+ * ``name``
993
+
994
+ The name of the histogram
995
+
996
+ / *Condition*: required / *Type*: str /
997
+
998
+ * ``value``
999
+
1000
+ The value assigned to the histogram.
1001
+
1002
+ / *Condition*: required / *Type*: int or float /
1003
+
1004
+ * ``labels``
1005
+
1006
+ A semicolon separated list of labels assigned to the histogram. The order of labels must fit to the order of label names like defined in ``add_histogram``.
1007
+
1008
+ / *Condition*: optional / *Type*: str / *Default*: None /
1009
+
1010
+ **Returns:**
1011
+
1012
+ * ``success``
1013
+
1014
+ / *Type*: bool /
1015
+
1016
+ Indicates if the computation of the keyword was successful or not
1017
+
1018
+ * ``result``
1019
+
1020
+ / *Type*: str /
1021
+
1022
+ The result of the computation of the keyword
1023
+ """
1024
+ success = False
1025
+ result = "UNKNOWN"
1026
+ if name is None:
1027
+ result = "Parameter 'name' not defined"
1028
+ return success, result
1029
+ if value is None:
1030
+ result = "Parameter 'value' not defined"
1031
+ return success, result
1032
+ value_type = type(value)
1033
+ value = self.convert_to_int_or_float(value)
1034
+ if value is None:
1035
+ success = False
1036
+ result = f"invalid type '{value_type}' of input parameter 'value'; expected int or float"
1037
+ return success, result
1038
+ if name not in self.__dictHistograms:
1039
+ result = f"Histogram '{name}' not defined"
1040
+ return success, result
1041
+ oHistogram = self.__dictHistograms[name]
1042
+ if labels is None:
1043
+ oHistogram.observe(value)
1044
+ else:
1045
+ labellist = labels.split(';')
1046
+ listLabelValues = []
1047
+ for label in labellist:
1048
+ label = label.strip()
1049
+ listLabelValues.append(label)
1050
+ oHistogram.labels(*listLabelValues).observe(value)
1051
+ success = True
1052
+ listResults = []
1053
+ listResults.append(f"Histogram '{name}' observed value {value}")
1054
+ if labels is not None:
1055
+ listResults.append(f"with labels: '{labels}'")
1056
+ result = " ".join(listResults)
1057
+ return success, result
1058
+ # eof def observe_histogram(...):
1059
+
696
1060
  # eof class prometheus_interface():
697
1061
 
@@ -17,16 +17,10 @@ Package Description
17
17
 
18
18
  The interface library **prometheus_interface** provides Robot Framework keywords to communicate with the monitoring system **Prometheus**.
19
19
 
20
-
21
- Currently this library is under development. We work on it. But what is available up to now, is not ready for being used in productive systems
22
- (but hopefully will be in near future).
23
-
24
-
25
-
26
20
  Package Documentation
27
21
  ---------------------
28
22
 
29
- A (growing) detailed documentation of the **prometheus_interface** can be found here:
23
+ A detailed documentation of the **prometheus_interface** can be found here:
30
24
 
31
25
  `PrometheusInterface.pdf <https://github.com/test-fullautomation/robotframework-prometheus/blob/develop/PrometheusInterface/PrometheusInterface.pdf>`_
32
26
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: robotframework-prometheus
3
- Version: 0.6.1
3
+ Version: 0.8.0
4
4
  Summary: Additional Robot Framework keywords
5
5
  Home-page: https://github.com/test-fullautomation/robotframework-prometheus
6
6
  Author: Holger Queckenstedt
@@ -22,15 +22,11 @@ Package Description
22
22
  The interface library **prometheus\_interface** provides Robot Framework
23
23
  keywords to communicate with the monitoring system **Prometheus**.
24
24
 
25
- Currently this library is under development. We work on it. But what is
26
- available up to now, is not ready for being used in productive systems
27
- (but hopefully will be in near future).
28
-
29
25
  Package Documentation
30
26
  ---------------------
31
27
 
32
- A (growing) detailed documentation of the **prometheus\_interface** can
33
- be found here:
28
+ A detailed documentation of the **prometheus\_interface** can be found
29
+ here:
34
30
 
35
31
  [PrometheusInterface.pdf](https://github.com/test-fullautomation/robotframework-prometheus/blob/develop/PrometheusInterface/PrometheusInterface.pdf)
36
32