def do_inc(): while True: job = jobs.get() if job is None: done.put(None) break statvent.incr("thread.test")
def main(): pid = os.getpid() print "stats being recorded to /tmp/stats-pipe/%d.stats" % pid print "Try 'cat /tmp/stats-pipe/%d.stats'" % pid # Start the thread that will write out stats to the pipe. statvent.start_recorder() # Track a bunch of boring demo stats. i = 0 while True: i += 1 statvent.incr('foo.bar', 1) statvent.set('foo :: now', time.time()) statvent.record('foo->baz->{0}', random.uniform(0.0, 5.0)) if i % 50 == 0: print "tick ..." time.sleep(.1)
def test_incr_increments_the_given_stat_value(): statvent.stats._stats['foo'] = 100 statvent.incr('foo') assert statvent.stats._stats['foo'] == 101
def test_incr_by_a_value_increments_by_that_value(): statvent.stats._stats['bar'] = 100 statvent.incr('bar', 100) assert statvent.stats._stats['bar'] == 200