Skip to content

Commit

Permalink
Added gauge to client
Browse files Browse the repository at this point in the history
  • Loading branch information
NorthIsUp committed Apr 3, 2012
1 parent eda9e80 commit ccd3618
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
9 changes: 8 additions & 1 deletion pystatsd/statsd.py
Expand Up @@ -35,7 +35,6 @@ def timing_since(self, stat, start, sample_rate=1):
""" """
self.timing(stat, int((time.time() - start) * 1000000), sample_rate) self.timing(stat, int((time.time() - start) * 1000000), sample_rate)



def timing(self, stat, time, sample_rate=1): def timing(self, stat, time, sample_rate=1):
""" """
Log timing information for a single stat Log timing information for a single stat
Expand All @@ -44,6 +43,14 @@ def timing(self, stat, time, sample_rate=1):
stats = {stat: "%f|ms" % time} stats = {stat: "%f|ms" % time}
self.send(stats, sample_rate) self.send(stats, sample_rate)


def gauge(self, stat, value, sample_rate=1):
"""
Log gauge information for a single stat
>>> statsd_client.gauge('some.gauge',42)
"""
stats = {stat: "%f|g" % value}
self.send(stats, sample_rate)

def increment(self, stats, sample_rate=1): def increment(self, stats, sample_rate=1):
""" """
Increments one or more stats counters Increments one or more stats counters
Expand Down
5 changes: 3 additions & 2 deletions statsd_test.py
Expand Up @@ -2,11 +2,12 @@


from pystatsd import Client, Server from pystatsd import Client, Server


sc = Client('localhost',8125) sc = Client('localhost', 8125)


sc.timing('python_test.time',500) sc.timing('python_test.time', 500)
sc.increment('python_test.inc_int') sc.increment('python_test.inc_int')
sc.decrement('python_test.decr_int') sc.decrement('python_test.decr_int')
sc.gauge('python_test.gauge', 42)


srvr = Server(debug=True) srvr = Server(debug=True)
srvr.serve() srvr.serve()

0 comments on commit ccd3618

Please sign in to comment.