Repository: Yelp/py_zipkin

Issue:
Error while encoding Json (_BaseJSONEncoder) 
I'm trying to use Encoding.V2_JSON \ Encoding.V1_JSON  but I'm receiving an exception:

```Traceback (most recent call last):
  File "/home/dmytro/anaconda3/lib/python3.6/site-packages/py_zipkin/logging_helper.py", line 129, in _emit_spans_with_span_sender
    report_timestamp=self.report_root_timestamp,
  File "/home/dmytro/anaconda3/lib/python3.6/site-packages/py_zipkin/logging_helper.py", line 180, in add_span
    encoded_span,
  File "/home/dmytro/anaconda3/lib/python3.6/site-packages/py_zipkin/encoding/_encoders.py", line 141, in fits
    return 2 + current_count + current_size + len(new_span) <= max_size
TypeError: unsupported operand type(s) for +: 'int' and 'list'
```

I use master branch, there is a similar exception for 0.14.1 (I switched to master hoping that the issue was fixed in master):

```Traceback (most recent call last):
  File "/home/dmytro/anaconda3/lib/python3.6/site-packages/py_zipkin/logging_helper.py", line 129, in _emit_spans_with_span_sender
    report_timestamp=self.report_root_timestamp,
  File "/home/dmytro/anaconda3/lib/python3.6/site-packages/py_zipkin/logging_helper.py", line 180, in add_span
    encoded_span,
  File "/home/dmytro/anaconda3/lib/python3.6/site-packages/py_zipkin/_encoding_helpers.py", line 343, in fits
    return 2 + current_count + current_size + len(new_span) <= max_size
TypeError: unsupported operand type(s) for +: 'int' and 'list'
```

I tried to debug a little: it seems `_BaseJSONEncoder.fits` expects an integer as the first argument but in `ZipkinBatchSender.add_span` we pass `self.queue` that is in fact a list

Discussion:

Patch:
diff --git a/py_zipkin/logging_helper.py b/py_zipkin/logging_helper.py
index 029fd8f..8fb8b64 100644
--- a/py_zipkin/logging_helper.py
+++ b/py_zipkin/logging_helper.py
@@ -174,10 +174,10 @@ class ZipkinBatchSender(object):
         is_over_size_limit = (
             self.max_payload_bytes is not None and
             not self.encoder.fits(
-                self.queue,
-                self.current_size,
-                self.max_payload_bytes,
-                encoded_span,
+                current_count=len(self.queue),
+                current_size=self.current_size,
+                max_size=self.max_payload_bytes,
+                new_span=encoded_span,
             )
         )
         is_over_portion_limit = len(self.queue) >= self.max_portion_size


Test patch:
diff --git a/tests/conftest.py b/tests/conftest.py
index f3a1841..7f7b7e4 100644
--- a/tests/conftest.py
+++ b/tests/conftest.py
@@ -1,5 +1,6 @@
 import mock
 import pytest
+import six
 
 from py_zipkin.encoding._encoders import IEncoder
 from py_zipkin.transport import BaseTransportHandler
@@ -46,8 +47,15 @@ class MockTransportHandler(BaseTransportHandler):
 class MockEncoder(IEncoder):
 
     def __init__(self, fits=True, encoded_span='', encoded_queue=''):
-        self.fits = mock.Mock(return_value=fits)
+        self.fits_bool = fits
         self.encode_span = mock.Mock(
             return_value=(encoded_span, len(encoded_span)),
         )
         self.encode_queue = mock.Mock(return_value=encoded_queue)
+
+    def fits(self, current_count, current_size, max_size, new_span):
+        assert isinstance(current_count, int)
+        assert isinstance(current_size, int)
+        assert isinstance(max_size, int)
+        assert isinstance(new_span, six.string_types)
+        return self.fits_bool
diff --git a/tests/integration/encoding_test.py b/tests/integration/encoding_test.py
index 44454fb..588c8c7 100644
--- a/tests/integration/encoding_test.py
+++ b/tests/integration/encoding_test.py
@@ -16,15 +16,7 @@ from py_zipkin.thrift import zipkin_core
 from py_zipkin import thrift
 from py_zipkin.util import generate_random_64bit_string
 from py_zipkin.zipkin import ZipkinAttrs
-
-
-def mock_logger():
-    mock_logs = []
-
-    def mock_transport_handler(message):
-        mock_logs.append(message)
-
-    return mock_transport_handler, mock_logs
+from tests.conftest import MockTransportHandler
 
 
 def _decode_binary_thrift_objs(obj):
@@ -243,7 +235,7 @@ def test_encoding(encoding, validate_fn):
         flags=None,
     )
     inner_span_id = generate_random_64bit_string()
-    mock_transport_handler, mock_logs = mock_logger()
+    mock_transport_handler = MockTransportHandler(10000)
     # Let's hardcode the timestamp rather than call time.time() every time.
     # The issue with time.time() is that the convertion to int of the
     # returned float value * 1000000 is not precise and in the same test
@@ -284,4 +276,5 @@ def test_encoding(encoding, validate_fn):
                         '2001:0db8:85a3:0000:0000:8a2e:0370:7334',
                     )
 
-    validate_fn(mock_logs[0], zipkin_attrs, inner_span_id, ts)
+    output = mock_transport_handler.get_payloads()[0]
+    validate_fn(output, zipkin_attrs, inner_span_id, ts)