Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use TBinaryProtocolAccelerated when serializing reports. #90

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions lightstep/crouton/ReportingService.py

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 6 additions & 3 deletions lightstep/thrift_connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import threading
from thrift import Thrift
from thrift.transport import THttpClient
from thrift.transport import TTransport
from thrift.protocol import TBinaryProtocol
from .crouton import ReportingService

Expand All @@ -21,6 +22,7 @@ class _ThriftConnection(object):
def __init__(self, collector_url):
self._collector_url = collector_url
self._lock = threading.Lock()
self._http_client = None
self._transport = None
self._client = None
self.ready = False
Expand All @@ -38,9 +40,10 @@ def open(self):
"""
self._lock.acquire()
try:
self._transport = THttpClient.THttpClient(self._collector_url)
self._http_client = THttpClient.THttpClient(self._collector_url)
self._transport = TTransport.TBufferedTransport(self._http_client)
self._transport.open()
protocol = TBinaryProtocol.TBinaryProtocol(self._transport)
protocol = TBinaryProtocol.TBinaryProtocolAccelerated(self._transport, fallback=True)
self._client = ReportingService.Client(protocol)
except Thrift.TException:
self._open_exceptions_count += 1
Expand All @@ -61,7 +64,7 @@ def report(self, *args, **kwargs):
try:
if self._client:
headers = {"Lightstep-Access-Token": args[0].access_token}
self._transport.setCustomHeaders(headers)
self._http_client.setCustomHeaders(headers)
resp = self._client.Report(*args, **kwargs)
self._report_consecutive_errors = 0
except Thrift.TException:
Expand Down