7from searx
import logger
10__all__ = [
"Histogram",
"HistogramStorage",
"CounterStorage"]
12logger = logger.getChild(
'searx.metrics')
17 _slots__ =
'_lock',
'_size',
'_sum',
'_quartiles',
'_count',
'_width'
28 q = int(value / self.
_width)
61 '''Quartile in percentage'''
71 x = decimal.Decimal(0)
72 width = decimal.Decimal(self.
_width)
73 width_exponent = -width.as_tuple().exponent
77 yp = int(y * 100 / self.
_count)
79 result[round(float(x), width_exponent)] = yp
85 x = decimal.Decimal(0)
86 width = decimal.Decimal(self.
_width)
87 stop_at_value = decimal.Decimal(self.
_count) / 100 * percentage
93 if sum_value >= stop_at_value:
104 __slots__ =
'measures',
'histogram_class'
119 return self.
measures.get(args,
None)
122 logger.debug(
"Histograms:")
123 ks = sorted(self.
measures.keys(), key=
'/'.join)
125 logger.debug(
"- %-60s %s",
'|'.join(k), self.
measures[k])
130 __slots__ =
'counters',
'lock'
147 def add(self, value, *args):
153 ks = sorted(self.
counters.keys(), key=
'/'.join)
154 logger.debug(
"Counters:")
156 logger.debug(
"- %-60s %s",
'|'.join(k), self.
counters[k])
164class VoidCounterStorage(CounterStorage):
165 def add(self, value, *args):
__init__(self, histogram_class=Histogram)
configure(self, width, size, *args)
quartile_percentage_map(self)
quartile_percentage(self)
percentage(self, percentage)
__init__(self, width=10, size=200)