Skip to content

Instantly share code, notes, and snippets.

@Dieterbe
Created December 14, 2012 18:17
Show Gist options
  • Save Dieterbe/4287415 to your computer and use it in GitHub Desktop.
Save Dieterbe/4287415 to your computer and use it in GitHub Desktop.
swift 1.7.4 statsd sampling fix
26c26
< from random import shuffle
---
> from random import random, shuffle
363a364
> self.random = random
380c381,384
< parts.append('@%s' % (sample_rate,))
---
> if self.random() < sample_rate:
> parts.append('@%s' % (sample_rate,))
> else:
> return
383c387
< with closing(socket.socket(socket.AF_INET, socket.SOCK_DGRAM)) as sock:
---
> with closing(self._open_socket()) as sock:
385a390,392
> def _open_socket(self):
> return socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment