def test_basic_registration_and_clear(): lb = Label("ping", "pong") rm = RootMetrics() rm.register(lb) assert rm.sample() == {"ping": "pong"} rm.clear() assert rm.sample() == {}
def test_register_string(): rm = RootMetrics() hello_gauge = rm.register('hello') assert rm.sample() == {'hello': None} hello_gauge.write('poop') assert rm.sample() == {'hello': 'poop'} rm.clear()
def test_register_string(): rm = RootMetrics() hello_gauge = rm.register('hello') assert rm.sample() == { 'hello': 'None' } hello_gauge.write('poop') assert rm.sample() == { 'hello': 'poop' } rm.clear()
def test_basic_registration_and_clear(): lb = Label('ping', 'pong') rm = RootMetrics() rm.register(lb) assert rm.sample() == {'ping': 'pong'} rm.clear() assert rm.sample() == {}
def test_register_string(): rm = RootMetrics() hello_gauge = rm.register("hello") assert rm.sample() == {"hello": None} hello_gauge.write("poop") assert rm.sample() == {"hello": "poop"} rm.clear()
def test_nontrivial_gauges(): for label_value in ["a", 0, 2.5, [1, 2, "3"], {"a": "b"}, {"c": None}, False]: lb = Label("ping", label_value) rm = RootMetrics() rm.register(lb) assert rm.sample() == {"ping": label_value} rm.clear() assert rm.sample() == {}
def test_nontrivial_gauges(): for label_value in ['a', 0, 2.5, [1,2,"3"], {'a': 'b'}, {'c': None}, False]: lb = Label('ping', label_value) rm = RootMetrics() rm.register(lb) assert rm.sample() == {'ping': label_value} rm.clear() assert rm.sample() == {}
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_nontrivial_gauges(): for label_value in [ 'a', 0, 2.5, [1, 2, "3"], { 'a': 'b' }, { 'c': None }, False ]: lb = Label('ping', label_value) rm = RootMetrics() rm.register(lb) assert rm.sample() == {'ping': label_value} rm.clear() assert rm.sample() == {}
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_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()