Skip to content

Commit

Permalink
add incr and decr aliases to client (because typing those extra 5 cha…
Browse files Browse the repository at this point in the history
…racters, my God.) Add debug-friendly repr() for client.
  • Loading branch information
sivy committed Jul 15, 2013
1 parent dc9a08a commit cefe780
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions pystatsd/statsd.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,13 +61,19 @@ def increment(self, stats, sample_rate=1):
"""
self.update_stats(stats, 1, sample_rate=sample_rate)

# alias
incr = increment

def decrement(self, stats, sample_rate=1):
"""
Decrements one or more stats counters
>>> statsd_client.decrement('some.int')
"""
self.update_stats(stats, -1, sample_rate=sample_rate)

# alias
decr = decrement

def update_stats(self, stats, delta, sample_rate=1):
"""
Updates one or more stats counters by arbitrary amounts
Expand Down Expand Up @@ -98,3 +104,6 @@ def send(self, data, sample_rate=1):
[self.udp_sock.sendto("%s:%s" % (stat, value), self.addr) for stat, value in sampled_data.iteritems()]
except:
self.log.exception("unexpected error")

def __repr__(self):
return "<pystatsd.statsd.Client addr=%s prefix=%s>" % (self.addr, self.prefix)

0 comments on commit cefe780

Please sign in to comment.