示例#1
0
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
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