Example #1
0
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() == {}
Example #2
0
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()
Example #3
0
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()
Example #4
0
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() == {}
Example #5
0
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()
Example #6
0
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() == {}
Example #7
0
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() == {}
Example #8
0
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() == {}
Example #9
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()
Example #10
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()
Example #11
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()
Example #12
0
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() == {}
Example #13
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()
Example #14
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()
Example #15
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()
Example #16
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()
Example #17
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()
Example #18
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()