Created
December 14, 2012 18:17
-
-
Save Dieterbe/4287415 to your computer and use it in GitHub Desktop.
swift 1.7.4 statsd sampling fix
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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