def add(self, labels: LabelsType, value: NumericValueType) -> None:
''' Add adds a single observation to the summary '''
value = cast(Union[float, int], value) # typing check, no runtime behaviour.
if type(value) not in (float, int):
raise TypeError("Summary only works with digits (int, float)")
try:
e = self.get_value(labels)
except KeyError:
# Initialize quantile estimator
e = quantile.Estimator(*self.invariants)
self.set_value(labels, e)
e.observe(float(value)) # type: ignore
# https://prometheus.io/docs/instrumenting/writing_clientlibs/#summary
# A summary MUST have the ``observe`` methods
评论列表
文章目录