Exemplo n.º 1
0
def test_basic_scoping():
    lb = Label("ping", "pong")
    rm = RootMetrics()
    rm.register(lb)
    rm.scope("bing").register(lb)
    assert rm.sample() == {"ping": "pong", "bing.ping": "pong"}
    rm.clear()
Exemplo n.º 2
0
def test_basic_scoping():
    lb = Label('ping', 'pong')
    rm = RootMetrics()
    rm.register(lb)
    rm.scope('bing').register(lb)
    assert rm.sample() == {'ping': 'pong', 'bing.ping': 'pong'}
    rm.clear()
Exemplo n.º 3
0
def test_basic_scoping():
  lb = Label('ping', 'pong')
  rm = RootMetrics()
  rm.register(lb)
  rm.scope('bing').register(lb)
  assert rm.sample() == { 'ping': 'pong', 'bing.ping': 'pong' }
  rm.clear()
Exemplo n.º 4
0
def test_scoped_registration_uses_references():
    mg = MutatorGauge("name", "brian")
    rm = RootMetrics()
    rm.scope("earth").register(mg)
    rm.scope("pluto").register(mg)
    assert rm.sample() == {"earth.name": "brian", "pluto.name": "brian"}
    mg.write("zargon")
    assert rm.sample() == {"earth.name": "zargon", "pluto.name": "zargon"}
    rm.clear()
Exemplo n.º 5
0
def test_scoped_registration_uses_references():
    mg = MutatorGauge('name', 'brian')
    rm = RootMetrics()
    rm.scope('earth').register(mg)
    rm.scope('pluto').register(mg)
    assert rm.sample() == {'earth.name': 'brian', 'pluto.name': 'brian'}
    mg.write('zargon')
    assert rm.sample() == {'earth.name': 'zargon', 'pluto.name': 'zargon'}
    rm.clear()
Exemplo n.º 6
0
def test_scoped_registration_uses_references():
  mg = MutatorGauge('name', 'brian')
  rm = RootMetrics()
  rm.scope('earth').register(mg)
  rm.scope('pluto').register(mg)
  assert rm.sample() == { 'earth.name': 'brian', 'pluto.name': 'brian' }
  mg.write('zargon')
  assert rm.sample() == { 'earth.name': 'zargon', 'pluto.name': 'zargon' }
  rm.clear()
Exemplo n.º 7
0
def test_bad_scope_names():
    rm = RootMetrics()
    my_scope = rm.scope("my_scope")
    with pytest.raises(TypeError):
        my_scope.scope(None)
    with pytest.raises(TypeError):
        my_scope.scope({})
    with pytest.raises(TypeError):
        my_scope.scope(123)
    with pytest.raises(TypeError):
        my_scope.scope(RootMetrics)
Exemplo n.º 8
0
def test_bad_scope_names():
    rm = RootMetrics()
    my_scope = rm.scope('my_scope')
    with pytest.raises(TypeError):
        my_scope.scope(None)
    with pytest.raises(TypeError):
        my_scope.scope({})
    with pytest.raises(TypeError):
        my_scope.scope(123)
    with pytest.raises(TypeError):
        my_scope.scope(RootMetrics)
Exemplo n.º 9
0
def test_nested_scopes():
    rm = RootMetrics()
    mg = rm.scope("a").scope("b").scope("c").register("123")
    mg.write(Amount(1, Time.MILLISECONDS))
    assert rm.sample() == {"a.b.c.123": "1 ms"}
    rm.clear()
Exemplo n.º 10
0
def test_nested_scopes():
    rm = RootMetrics()
    mg = rm.scope('a').scope('b').scope('c').register('123')
    mg.write(Amount(1, Time.MILLISECONDS))
    assert rm.sample() == {'a.b.c.123': '1 ms'}
    rm.clear()
Exemplo n.º 11
0
def test_nested_scopes():
  rm = RootMetrics()
  mg = rm.scope('a').scope('b').scope('c').register('123')
  mg.write(Amount(1, Time.MILLISECONDS))
  assert rm.sample() == {'a.b.c.123': '1 ms'}
  rm.clear()