Skip to content

Commit

Permalink
Merge pull request #886 from deniszh/backport/1.1.x/pr-885
Browse files Browse the repository at this point in the history
[1.1.x] Fix missing encoding for line protocol (#885)
  • Loading branch information
deniszh authored Mar 3, 2020
2 parents 4c60b01 + 080a8aa commit 9d0f58b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
3 changes: 2 additions & 1 deletion lib/carbon/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -484,7 +484,8 @@ def _sendDatapointsNow(self, datapoints):
value = ("%.10f" % datapoint[1]).rstrip('0').rstrip('.')
else:
value = "%d" % datapoint[1]
self.sendLine("%s %s %d" % (metric, value, datapoint[0]))
to_send = "%s %s %d" % (metric, value, datapoint[0])
self.sendLine(to_send.encode('utf-8'))


class CarbonLineClientFactory(CarbonClientFactory):
Expand Down
10 changes: 5 additions & 5 deletions lib/carbon/tests/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,11 @@ def setUp(self):

def test_send_datapoints(self):
calls = [
(('foo.bar', (1000000000, 1.0)), "foo.bar 1 1000000000"),
(('foo.bar', (1000000000, 1.1)), "foo.bar 1.1 1000000000"),
(('foo.bar', (1000000000, 1.123456789123)), "foo.bar 1.1234567891 1000000000"),
(('foo.bar', (1000000000, 1)), "foo.bar 1 1000000000"),
(('foo.bar', (1000000000, 1.498566361088E12)), "foo.bar 1498566361088 1000000000"),
(('foo.bar', (1000000000, 1.0)), b'foo.bar 1 1000000000'),
(('foo.bar', (1000000000, 1.1)), b'foo.bar 1.1 1000000000'),
(('foo.bar', (1000000000, 1.123456789123)), b'foo.bar 1.1234567891 1000000000'),
(('foo.bar', (1000000000, 1)), b'foo.bar 1 1000000000'),
(('foo.bar', (1000000000, 1.498566361088E12)), b'foo.bar 1498566361088 1000000000'),
]

i = 0
Expand Down

0 comments on commit 9d0f58b

Please sign in to comment.