Skip to content

Commit

Permalink
[dogstatsd] support unicode tags 🔣
Browse files Browse the repository at this point in the history
Using unicode with DogStatsD tags causes `UnicodeDecodeError`
exceptions.

Do not raise on unicode tags. Fix #132.
  • Loading branch information
yannmh committed Aug 24, 2016
1 parent be01e58 commit e2ae0ff
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion datadog/dogstatsd/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ def _report(self, metric, metric_type, value, tags, sample_rate):
if tags:
payload.extend(["|#", ",".join(tags)])

encoded = "".join(imap(str, payload))
encoded = "".join(imap(unicode, payload))

# Send it
self._send(encoded)
Expand Down
4 changes: 2 additions & 2 deletions tests/unit/dogstatsd/test_statsd.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,8 @@ def test_tagged_gauge(self):
t.assert_equal('gt:123.4|g|#country:china,age:45,blue', self.recv())

def test_tagged_counter(self):
self.statsd.increment('ct', tags=['country:canada', 'red'])
t.assert_equal('ct:1|c|#country:canada,red', self.recv())
self.statsd.increment('ct', tags=[u'country:españa', 'red'])
t.assert_equal(u'ct:1|c|#country:españa,red', self.recv())

def test_tagged_histogram(self):
self.statsd.histogram('h', 1, tags=['red'])
Expand Down

0 comments on commit e2ae0ff

Please sign in to comment.