Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Added gauge to client

  • Loading branch information...
commit ccd36188bc86ed2f6747bc39305fdf50cee8ccb8 1 parent eda9e80
@NorthIsUp NorthIsUp authored
Showing with 11 additions and 3 deletions.
  1. +8 −1 pystatsd/statsd.py
  2. +3 −2 statsd_test.py
View
9 pystatsd/statsd.py
@@ -35,7 +35,6 @@ def timing_since(self, stat, start, sample_rate=1):
"""
self.timing(stat, int((time.time() - start) * 1000000), sample_rate)
-
def timing(self, stat, time, sample_rate=1):
"""
Log timing information for a single stat
@@ -44,6 +43,14 @@ def timing(self, stat, time, sample_rate=1):
stats = {stat: "%f|ms" % time}
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):
"""
Increments one or more stats counters
View
5 statsd_test.py
@@ -2,11 +2,12 @@
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.decrement('python_test.decr_int')
+sc.gauge('python_test.gauge', 42)
srvr = Server(debug=True)
srvr.serve()
Please sign in to comment.
Something went wrong with that request. Please try again.