예제 #1
0
파일: varz.py 프로젝트: CodeWarltz/commons
class StatusStats(Observable):
  def __init__(self):
    self._count = AtomicGauge('count')
    self._ns = AtomicGauge('total_ns')
    self.metrics.register(self._count)
    self.metrics.register(self._ns)

  def increment(self, ns):
    self._count.increment()
    self._ns.add(ns)
예제 #2
0
def test_atomic_gauge_types():
  with pytest.raises(TypeError):
    ag = AtomicGauge('a', None)
  with pytest.raises(TypeError):
    ag = AtomicGauge('a', 'hello')
  ag = AtomicGauge('a', 23)
  with pytest.raises(TypeError):
    ag.add(None)
  with pytest.raises(TypeError):
    ag.add('hello')
예제 #3
0
파일: varz.py 프로젝트: wcauchois/commons-1
class StatusStats(Observable):
    def __init__(self):
        self._count = AtomicGauge('count')
        self._ns = AtomicGauge('total_ns')
        self.metrics.register(self._count)
        self.metrics.register(self._ns)

    def increment(self, ns):
        self._count.increment()
        self._ns.add(ns)
예제 #4
0
def test_atomic_gauge():
  ag = AtomicGauge('a')
  assert ag.name() == 'a'
  assert ag.read() == 0
  assert ag.add(-2) == -2
  ag = AtomicGauge('a')
  assert ag.decrement() == -1