-
Notifications
You must be signed in to change notification settings - Fork 39
Expand file tree
/
Copy pathaverage.py
More file actions
28 lines (21 loc) · 814 Bytes
/
average.py
File metadata and controls
28 lines (21 loc) · 814 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import statsd
class Average(statsd.Client):
'''Class to implement a statsd "average" message.
This value will be averaged against other messages before being
sent.
See https://github.com/chuyskywalker/statsd/blob/master/README.md for
more info.
>>> average = Average('application_name')
>>> # do something here
>>> average.send('subname', 123)
True
'''
def send(self, subname, value):
'''Send the data to statsd via self.connection
:keyword subname: The subname to report the data to (appended to the
client name)
:keyword value: The raw value to send
'''
name = self._get_name(self.name, subname)
self.logger.info('%s: %d', name, value)
return statsd.Client._send(self, {name: '%d|a' % value})