Skip to content

Commit

Permalink
fix sampling
Browse files Browse the repository at this point in the history
  • Loading branch information
Steve Ivy authored and kastner committed Feb 17, 2011
1 parent 819a86d commit e58b631
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions python_example.py
Expand Up @@ -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)

Expand Down Expand Up @@ -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

Expand Down

0 comments on commit e58b631

Please sign in to comment.