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()
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()
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()
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()
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()
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()
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)
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)
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()
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()