Permalink
Browse files

Merge pull request #22 from mozilla-services/vng/incr.fix

Vng/incr.fix
  • Loading branch information...
2 parents bb11def + e5e3302 commit e87ea30ad49ed8ab53bf4ea3a976fea525c6fbc9 Rob Miller committed May 29, 2012
Showing with 6 additions and 1 deletion.
  1. +2 −1 metlog/client.py
  2. +3 −0 metlog/tests/test_client.py
  3. +1 −0 metlog/tests/test_decorators.py
View
3 metlog/client.py
@@ -276,7 +276,7 @@ def timing(self, timer, elapsed):
payload, fields)
def incr(self, name, count=1, timestamp=None, logger=None, severity=None,
- fields=None):
+ fields=None, rate=1.0):
"""
Sends an 'increment counter' message.
@@ -290,6 +290,7 @@ def incr(self, name, count=1, timestamp=None, logger=None, severity=None,
payload = str(count)
fields = fields if fields is not None else dict()
fields['name'] = name
+ fields['rate'] = rate
self.metlog('counter', timestamp, logger, severity, payload, fields)
# Standard Python logging API emulation
View
3 metlog/tests/test_client.py
@@ -124,10 +124,13 @@ def timed():
def test_incr(self):
name = 'incr'
self.client.incr(name)
+
full_msg = self._extract_full_msg()
eq_(full_msg['type'], 'counter')
eq_(full_msg['logger'], self.logger)
eq_(full_msg['fields']['name'], name)
+ # You have to have a rate set here
+ eq_(full_msg['fields']['rate'], 1)
eq_(full_msg['payload'], '1')
self.client.incr(name, 10)
View
1 metlog/tests/test_decorators.py
@@ -98,6 +98,7 @@ def simple(x, y):
expected = {'severity': 2, 'timestamp': 0,
'fields': {'name': 'qdo.foo',
+ 'rate': 1.0,
},
'logger': 'somelogger', 'type': 'counter',
'payload': '5', 'env_version': '0.8',

0 comments on commit e87ea30

Please sign in to comment.