Skip to content

Commit

Permalink
fix type annotation for protobuf serialized data (open-telemetry#3699)
Browse files Browse the repository at this point in the history
  • Loading branch information
methane authored Feb 29, 2024
1 parent 9481893 commit d01dbc2
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -103,15 +103,15 @@ def __init__(
)
self._shutdown = False

def _export(self, serialized_data: str):
def _export(self, serialized_data: bytes):
data = serialized_data
if self._compression == Compression.Gzip:
gzip_data = BytesIO()
with gzip.GzipFile(fileobj=gzip_data, mode="w") as gzip_stream:
gzip_stream.write(serialized_data)
data = gzip_data.getvalue()
elif self._compression == Compression.Deflate:
data = zlib.compress(bytes(serialized_data))
data = zlib.compress(serialized_data)

return self._session.post(
url=self._endpoint,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,15 +139,15 @@ def __init__(
preferred_temporality, preferred_aggregation
)

def _export(self, serialized_data: str):
def _export(self, serialized_data: bytes):
data = serialized_data
if self._compression == Compression.Gzip:
gzip_data = BytesIO()
with gzip.GzipFile(fileobj=gzip_data, mode="w") as gzip_stream:
gzip_stream.write(serialized_data)
data = gzip_data.getvalue()
elif self._compression == Compression.Deflate:
data = zlib.compress(bytes(serialized_data))
data = zlib.compress(serialized_data)

return self._session.post(
url=self._endpoint,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,15 +101,15 @@ def __init__(
)
self._shutdown = False

def _export(self, serialized_data: str):
def _export(self, serialized_data: bytes):
data = serialized_data
if self._compression == Compression.Gzip:
gzip_data = BytesIO()
with gzip.GzipFile(fileobj=gzip_data, mode="w") as gzip_stream:
gzip_stream.write(serialized_data)
data = gzip_data.getvalue()
elif self._compression == Compression.Deflate:
data = zlib.compress(bytes(serialized_data))
data = zlib.compress(serialized_data)

return self._session.post(
url=self._endpoint,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def content_type():

def serialize(
self, spans: Sequence[Span], local_endpoint: NodeEndpoint
) -> str:
) -> bytes:
encoded_local_endpoint = self._encode_local_endpoint(local_endpoint)
# pylint: disable=no-member
encoded_spans = zipkin_pb2.ListOfSpans()
Expand Down

0 comments on commit d01dbc2

Please sign in to comment.