lookout.core.metrics¶
Module Contents¶
-
lookout.core.metrics.PROMETHEUS_HOST¶
-
lookout.core.metrics.PROMETHEUS_PORT¶
-
class
lookout.core.metrics.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.
-
set(self, value)¶ Set the value to the given amount. Thread safe.
-
get(self)¶ Read the current value. Thread safe.
-
-
class
lookout.core.metrics.ConfidentCounter¶ Bases:
prometheus_client.metrics.MetricWrapperBasePrometheus 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.
-
lookout.core.metrics.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.
Parameters: - key – Identifier of the event.
- value – Value of the event. It will convert cast variables to int.
- description – Additional description of the event. Only used when creating a new event.
Returns: None
-
class
lookout.core.metrics.PrometheusServer(host:str, port:int)¶ Manage the streaming process for different metrics.
-
port¶ Return the port where the server is running.
-
host¶ Return the address where the server is running.
-
metrics¶ Return the metrics stored in the server.
-
create_new_metric(self, name:str, description:str='')¶ Create a new metric in case it does not previously exists.
Parameters: - name – It will be used as a key to identify the new metric.
- description – Additional description of the event. Only used when creating a new event.
Returns: None
-
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.Parameters: - key – Identifier of the event.
- value – Value of the event. It will convert cast variables to int.
- description – Additional description of the event. Only used when creating a new event.
Returns: None
-