robotframework-prometheus 0.6.1__tar.gz → 0.9.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.
Files changed (20) hide show
  1. robotframework_prometheus-0.9.0/MANIFEST.in +1 -0
  2. robotframework_prometheus-0.9.0/PKG-INFO +173 -0
  3. robotframework_prometheus-0.9.0/PrometheusInterface/PrometheusInterface.pdf +0 -0
  4. {robotframework-prometheus-0.6.1 → robotframework_prometheus-0.9.0}/PrometheusInterface/__init__.py +1 -1
  5. {robotframework-prometheus-0.6.1 → robotframework_prometheus-0.9.0}/PrometheusInterface/prometheus_interface.py +395 -31
  6. robotframework_prometheus-0.9.0/README.rst +143 -0
  7. robotframework_prometheus-0.9.0/build_backend.py +97 -0
  8. robotframework_prometheus-0.9.0/pyproject.toml +125 -0
  9. robotframework_prometheus-0.9.0/robotframework_prometheus.egg-info/PKG-INFO +173 -0
  10. {robotframework-prometheus-0.6.1 → robotframework_prometheus-0.9.0}/robotframework_prometheus.egg-info/SOURCES.txt +3 -1
  11. robotframework_prometheus-0.9.0/robotframework_prometheus.egg-info/requires.txt +12 -0
  12. robotframework-prometheus-0.6.1/PKG-INFO +0 -78
  13. robotframework-prometheus-0.6.1/PrometheusInterface/PrometheusInterface.pdf +0 -0
  14. robotframework-prometheus-0.6.1/README.rst +0 -73
  15. robotframework-prometheus-0.6.1/robotframework_prometheus.egg-info/PKG-INFO +0 -78
  16. robotframework-prometheus-0.6.1/robotframework_prometheus.egg-info/requires.txt +0 -3
  17. robotframework-prometheus-0.6.1/setup.py +0 -224
  18. {robotframework-prometheus-0.6.1 → robotframework_prometheus-0.9.0}/robotframework_prometheus.egg-info/dependency_links.txt +0 -0
  19. {robotframework-prometheus-0.6.1 → robotframework_prometheus-0.9.0}/robotframework_prometheus.egg-info/top_level.txt +0 -0
  20. {robotframework-prometheus-0.6.1 → robotframework_prometheus-0.9.0}/setup.cfg +0 -0
@@ -0,0 +1 @@
1
+ include build_backend.py
@@ -0,0 +1,173 @@
1
+ Metadata-Version: 2.4
2
+ Name: robotframework-prometheus
3
+ Version: 0.9.0
4
+ Summary: Robot Framework keywords to communicate with the monitoring system Prometheus
5
+ Author-email: Holger Queckenstedt <Holger.Queckenstedt@de.bosch.com>
6
+ License-Expression: Apache-2.0
7
+ Project-URL: Homepage, https://pypi.org/project/robotframework-prometheus/
8
+ Project-URL: Documentation, https://github.com/test-fullautomation/robotframework-prometheus/blob/develop/PrometheusInterface/PrometheusInterface.pdf
9
+ Project-URL: Readme, https://github.com/test-fullautomation/robotframework-prometheus/blob/develop/README.rst
10
+ Project-URL: Repository, https://github.com/test-fullautomation/robotframework-prometheus
11
+ Project-URL: Issues, https://github.com/test-fullautomation/robotframework-prometheus/issues
12
+ Keywords: robotframework,stringfunctions
13
+ Classifier: Development Status :: 4 - Beta
14
+ Classifier: Intended Audience :: Developers
15
+ Classifier: Programming Language :: Python :: 3
16
+ Classifier: Operating System :: OS Independent
17
+ Classifier: Topic :: Software Development
18
+ Requires-Python: >=3.11
19
+ Description-Content-Type: text/x-rst
20
+ Requires-Dist: robotframework>=6.1
21
+ Requires-Dist: colorama
22
+ Requires-Dist: prometheus-client
23
+ Requires-Dist: GenPackageDoc
24
+ Requires-Dist: PythonExtensionsCollection
25
+ Provides-Extra: dev
26
+ Requires-Dist: pytest>=6.0; extra == "dev"
27
+ Requires-Dist: pytest-cov>=3.0; extra == "dev"
28
+ Provides-Extra: docs
29
+ Requires-Dist: docutils>=0.22.4; extra == "docs"
30
+
31
+ .. Copyright 2020-2026 Robert Bosch GmbH
32
+
33
+ .. Licensed under the Apache License, Version 2.0 (the "License");
34
+ you may not use this file except in compliance with the License.
35
+ You may obtain a copy of the License at
36
+
37
+ .. http://www.apache.org/licenses/LICENSE-2.0
38
+
39
+ .. Unless required by applicable law or agreed to in writing, software
40
+ distributed under the License is distributed on an "AS IS" BASIS,
41
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
42
+ See the License for the specific language governing permissions and
43
+ limitations under the License.
44
+
45
+ Package Description
46
+ ===================
47
+
48
+ The interface library **robotframework-prometheus** provides Robot Framework keywords to communicate with the monitoring system **Prometheus**.
49
+
50
+ How to install
51
+ --------------
52
+
53
+ The interface library **robotframework-prometheus** can be installed in two different ways.
54
+
55
+ 1. Installation via PyPi (recommended for users)
56
+
57
+ .. code::
58
+
59
+ pip install robotframework-prometheus
60
+
61
+ `robotframework-prometheus in PyPi <https://pypi.org/project/robotframework-prometheus/>`_
62
+
63
+ 2. Installation via GitHub (recommended for developers)
64
+
65
+ * Clone the **robotframework-prometheus** repository to your machine.
66
+
67
+ .. code::
68
+
69
+ git clone https://github.com/test-fullautomation/robotframework-prometheus.git
70
+
71
+ `robotframework-prometheus in GitHub <https://github.com/test-fullautomation/robotframework-prometheus>`_
72
+
73
+ * Use the following command to install **robotframework-prometheus** (executed in repository main folder):
74
+
75
+ .. code::
76
+
77
+ python -m pip install .
78
+
79
+ Or:
80
+
81
+ .. code::
82
+
83
+ python -m pip install --proxy <proxy> .
84
+
85
+ This command will also download and install all dependencies that are required to work with the source files in the current repository.
86
+ After the initial installation of **robotframework-prometheus** is done, you have the following two possibilities:
87
+
88
+ 1. *Clean the previous installation*:
89
+
90
+ .. code::
91
+
92
+ python "./cleanup_installation.py"
93
+
94
+ ``cleanup_installation.py`` explicitly deletes all files and folders within the component installation folder under
95
+ ``site-packages`` and also deletes local build artefacts.
96
+
97
+ 2. *Render the component documentation*:
98
+
99
+ .. code::
100
+
101
+ python "./genpackagedoc.py"
102
+
103
+ This would e.g. be required in case of changes in the interface of **robotframework-prometheus**.
104
+
105
+ The documentation is rendered by a separate application called **GenPackageDoc**, that is part
106
+ of the build dependencies and runtime dependencies of **robotframework-prometheus**.
107
+
108
+ **GenPackageDoc** needs to be configured. Details about how to do this, can be found in the
109
+ `README.rst <https://github.com/test-fullautomation/python-genpackagedoc/blob/develop/README.rst>`_
110
+ (sections *Install dependencies* and *Configure dependencies*).
111
+
112
+ * Use the following command to build **robotframework-prometheus** (executed in repository main folder):
113
+
114
+ .. code::
115
+
116
+ python -m build .
117
+
118
+ Or:
119
+
120
+ .. code::
121
+
122
+ python -m pip config set global.proxy <proxy>
123
+ python -m build .
124
+
125
+
126
+ Package Documentation
127
+ ---------------------
128
+
129
+ A detailed documentation of the **prometheus_interface** can be found here:
130
+
131
+ `PrometheusInterface.pdf <https://github.com/test-fullautomation/robotframework-prometheus/blob/develop/PrometheusInterface/PrometheusInterface.pdf>`_
132
+
133
+ Feedback
134
+ --------
135
+
136
+ To give us a feedback, you can send an email to `Thomas Pollerspöck <mailto:Thomas.Pollerspoeck@de.bosch.com>`_
137
+
138
+ In case you want to report a bug or request any interesting feature, please don't hesitate to raise a ticket.
139
+
140
+ Maintainers
141
+ -----------
142
+
143
+ `Holger Queckenstedt <mailto:Holger.Queckenstedt@de.bosch.com>`_
144
+
145
+ `Thomas Pollerspöck <mailto:Thomas.Pollerspoeck@de.bosch.com>`_
146
+
147
+ Contributors
148
+ ------------
149
+
150
+ `Holger Queckenstedt <mailto:Holger.Queckenstedt@de.bosch.com>`_
151
+
152
+ `Thomas Pollerspöck <mailto:Thomas.Pollerspoeck@de.bosch.com>`_
153
+
154
+ License
155
+ -------
156
+
157
+ Copyright 2020-2026 Robert Bosch GmbH
158
+
159
+ Licensed under the Apache License, Version 2.0 (the "License");
160
+ you may not use this file except in compliance with the License.
161
+ You may obtain a copy of the License at
162
+
163
+ |License: Apache v2|
164
+
165
+ Unless required by applicable law or agreed to in writing, software
166
+ distributed under the License is distributed on an "AS IS" BASIS,
167
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
168
+ See the License for the specific language governing permissions and
169
+ limitations under the License.
170
+
171
+
172
+ .. |License: Apache v2| image:: https://img.shields.io/pypi/l/robotframework.svg
173
+ :target: http://www.apache.org/licenses/LICENSE-2.0.html
@@ -1,4 +1,4 @@
1
- # Copyright 2020-2024 Robert Bosch GmbH
1
+ # Copyright 2020-2026 Robert Bosch GmbH
2
2
  #
3
3
  # Licensed under the Apache License, Version 2.0 (the "License");
4
4
  # you may not use this file except in compliance with the License.
@@ -1,4 +1,4 @@
1
- # Copyright 2020-2024 Robert Bosch GmbH
1
+ # Copyright 2020-2026 Robert Bosch GmbH
2
2
  #
3
3
  # Licensed under the Apache License, Version 2.0 (the "License");
4
4
  # you may not use this file except in compliance with the License.
@@ -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.9.0"
36
+ LIBRARY_VERSION_DATE = "23.02.2026"
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