Example #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()
Example #2
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 #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()
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_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 #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
File: varz.py Project: xianxu/pants
def register_build_properties():
    if not HAS_PEX:
        return
    rm = RootMetrics().scope('build')
    try:
        build_properties = PEX().info.build_properties
    except PEX.NotFound:
        return
    for key, value in build_properties.items():
        rm.register(Label(str(key), str(value)))
Example #10
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 #11
0
    def test_filtering_vars_filter_enabled_and_not_requested(self):
        rm = RootMetrics()
        zone = NamedGauge('alpha', "wont_be_visible")
        alpha = NamedGauge('zone', "smf1")
        rm.register(zone)
        rm.register(alpha)

        metrics = RootMetrics()
        vars_subsystem = VarsSubsystem()
        regex = vars_subsystem.compile_stats_filters(["alpha", "beta.*"])
        endpoint = VarsEndpoint(period=Amount(60000, Time.MILLISECONDS),
                                stats_filter=regex)
        metrics_returned = endpoint.handle_vars_json()
        assert "zone" in metrics_returned
        assert "alpha" in metrics_returned
        request.GET.replace('filtered', None)
Example #12
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 #13
0
File: varz.py Project: xianxu/pants
def register_diagnostics():
    import os, sys, time
    rm = RootMetrics().scope('sys')
    now = time.time()
    rm.register(LambdaGauge('uptime', lambda: time.time() - now))
    rm.register(Label('argv', repr(sys.argv)))
    rm.register(Label('path', repr(sys.path)))
    rm.register(LambdaGauge('modules', lambda: ', '.join(sys.modules.keys())))
    rm.register(Label('version', sys.version))
    rm.register(Label('platform', sys.platform))
    rm.register(Label('executable', sys.executable))
    rm.register(Label('prefix', sys.prefix))
    rm.register(Label('exec_prefix', sys.exec_prefix))
    rm.register(Label('uname', ' '.join(os.uname())))