зеркало из https://github.com/microsoft/statsd.git
examples: python: inline sample_send
This commit is contained in:
Родитель
386089964b
Коммит
0a2ccff064
|
@ -58,20 +58,10 @@ class StatsdClient(object):
|
||||||
data = {}
|
data = {}
|
||||||
for stat in stats:
|
for stat in stats:
|
||||||
data[stat] = "{0}|c".format(delta)
|
data[stat] = "{0}|c".format(delta)
|
||||||
self.sample_send(data, sample_rate)
|
self.send(self.sample(data, sample_rate), self.addr)
|
||||||
|
|
||||||
def sample_send(self, data, sample_rate=1):
|
|
||||||
"""
|
|
||||||
Sample and squirt the metrics over UDP
|
|
||||||
|
|
||||||
>>> client = StatsdClient()
|
|
||||||
>>> client.sample_send({"example.sample_send": "13|c"}, 1)
|
|
||||||
True
|
|
||||||
"""
|
|
||||||
return self.send(self.sample(data, sample_rate), self.addr)
|
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def sample(data, sample_rate=1):
|
def sample(data, sample_rate):
|
||||||
"""
|
"""
|
||||||
Sample data dict
|
Sample data dict
|
||||||
TODO(rbtz@): Convert to generator
|
TODO(rbtz@): Convert to generator
|
||||||
|
|
Загрузка…
Ссылка в новой задаче