Skip to content

Commit

Permalink
examples: python: simplify fastpath
Browse files Browse the repository at this point in the history
  • Loading branch information
SaveTheRbtz committed Dec 23, 2012
1 parent 7adbbc0 commit ca06735
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions examples/python_example.py
Expand Up @@ -122,16 +122,15 @@ def sample(data, sample_rate):
>>> StatsdClient.sample({"example.sample5": "5", "example.sample7": "7"}, 0.01)
{}
"""
sampled_data = {}
if 0 < sample_rate < 1:
if sample_rate >= 1:
return data
elif sample_rate < 1:
if random() <= sample_rate:
sampled_data = {}
for stat, value in data.items():
sampled_data[stat] = "{0}|@{1}".format(value, sample_rate)
elif sample_rate == 0:
sampled_data = {}
else:
sampled_data = data
return sampled_data
return sampled_data
return {}

@staticmethod
def send(_dict, addr):
Expand Down

0 comments on commit ca06735

Please sign in to comment.