:mod:`lookout.core.metrics` =========================== .. py:module:: lookout.core.metrics Module Contents --------------- .. data:: PROMETHEUS_HOST .. data:: PROMETHEUS_PORT .. py:class:: PreciseFloat A floating-point value. It is possible to add numbers to it, and the result is guaranteed to be precise thanks to Kahan summation algorithm. That addition operation is thread safe. .. method:: set(self, value) Set the value to the given amount. Thread safe. .. method:: get(self) Read the current value. Thread safe. .. py:class:: ConfidentCounter Bases::class:`prometheus_client.metrics.MetricWrapperBase` Prometheus Counter-like class. It enables calculation of the rolling mean, and standard deviation. This class internally reports the number of events, the sum of event values, and the sum of squares of event values to Prometheus. .. function:: record_event(key:str, value:Union[int, float, bool], description:str='') Register an event by a key and with a numeric value. If the key does not exist, it creates a new Prometheus Metric. :param key: Identifier of the event. :param value: Value of the event. It will convert cast variables to int. :param description: Additional description of the event. Only used when creating a new event. :return: None .. py:class:: PrometheusServer(host:str, port:int) Manage the streaming process for different metrics. .. attribute:: port Return the port where the server is running. .. attribute:: host Return the address where the server is running. .. attribute:: metrics Return the metrics stored in the server. .. method:: create_new_metric(self, name:str, description:str='') Create a new metric in case it does not previously exists. :param name: It will be used as a key to identify the new metric. :param description: Additional description of the event. Only used when creating a new event. :return: None .. method:: submit_event(self, key:str, value:Union[int, float, bool], description:str='') Register an event by a key and with a numeric value. If the key does not exist, it creates a new Prometheus Metric. :param key: Identifier of the event. :param value: Value of the event. It will convert cast variables to int. :param description: Additional description of the event. Only used when creating a new event. :return: None