Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

fix sampling

  • Loading branch information...
commit e58b63174f027c4f9f73fef6b980e134fcd1854f 1 parent 819a86d
Steve Ivy authored kastner committed
Showing with 7 additions and 4 deletions.
  1. +7 −4 python_example.py
11 python_example.py
View
@@ -24,6 +24,7 @@ def increment(stats, sample_rate=1):
"""
Increments one or more stats counters
>>> Statsd.increment('some.int')
+ >>> Statsd.increment('some.int',0.5)
"""
Statsd.update_stats(stats, 1, sample_rate)
@@ -62,12 +63,14 @@ def send(data, sample_rate=1):
except Error:
exit(1)
- sampled_data = []
+ sampled_data = {}
if(sample_rate < 1):
- pass
- # for (stat in data.keys):
- # value = data[stat]
+ import random
+ if random.random() <= sample_rate:
+ for stat in data.keys():
+ value = data[stat]
+ sampled_data[stat] = "%s|@%s" %(value, sample_rate)
else:
sampled_data=data
Please sign in to comment.
Something went wrong with that request. Please try again.