collectors.py 文件源码

python
阅读 27 收藏 0 点赞 0 评论 0

项目:aioprometheus 作者: claws 项目源码 文件源码
def add(self, labels: LabelsType, value: NumericValueType) -> None:
        ''' Add will add the given value to the counter.

        :raises: ValueError if the value is negative. Counters can only
          increase.
        '''
        value = cast(Union[float, int], value)  # typing check, no runtime behaviour.
        if value < 0:
            raise ValueError("Counters can't decrease")

        try:
            current = self.get_value(labels)
        except KeyError:
            current = 0

        current = cast(Union[float, int], current)  # typing check, no runtime behaviour.
        self.set_value(labels, current + value)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号