From d01dbc219ce5a853cf72a8854d45701724e334b6 Mon Sep 17 00:00:00 2001 From: Inada Naoki Date: Thu, 29 Feb 2024 12:52:10 +0900 Subject: [PATCH] fix type annotation for protobuf serialized data (#3699) --- .../exporter/otlp/proto/http/_log_exporter/__init__.py | 4 ++-- .../exporter/otlp/proto/http/metric_exporter/__init__.py | 4 ++-- .../exporter/otlp/proto/http/trace_exporter/__init__.py | 4 ++-- .../opentelemetry/exporter/zipkin/proto/http/v2/__init__.py | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/exporter/opentelemetry-exporter-otlp-proto-http/src/opentelemetry/exporter/otlp/proto/http/_log_exporter/__init__.py b/exporter/opentelemetry-exporter-otlp-proto-http/src/opentelemetry/exporter/otlp/proto/http/_log_exporter/__init__.py index 4703b102863..902ac5f2429 100644 --- a/exporter/opentelemetry-exporter-otlp-proto-http/src/opentelemetry/exporter/otlp/proto/http/_log_exporter/__init__.py +++ b/exporter/opentelemetry-exporter-otlp-proto-http/src/opentelemetry/exporter/otlp/proto/http/_log_exporter/__init__.py @@ -103,7 +103,7 @@ 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() @@ -111,7 +111,7 @@ def _export(self, serialized_data: str): 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, diff --git a/exporter/opentelemetry-exporter-otlp-proto-http/src/opentelemetry/exporter/otlp/proto/http/metric_exporter/__init__.py b/exporter/opentelemetry-exporter-otlp-proto-http/src/opentelemetry/exporter/otlp/proto/http/metric_exporter/__init__.py index 6be74a37a06..57e030bd549 100644 --- a/exporter/opentelemetry-exporter-otlp-proto-http/src/opentelemetry/exporter/otlp/proto/http/metric_exporter/__init__.py +++ b/exporter/opentelemetry-exporter-otlp-proto-http/src/opentelemetry/exporter/otlp/proto/http/metric_exporter/__init__.py @@ -139,7 +139,7 @@ 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() @@ -147,7 +147,7 @@ def _export(self, serialized_data: str): 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, diff --git a/exporter/opentelemetry-exporter-otlp-proto-http/src/opentelemetry/exporter/otlp/proto/http/trace_exporter/__init__.py b/exporter/opentelemetry-exporter-otlp-proto-http/src/opentelemetry/exporter/otlp/proto/http/trace_exporter/__init__.py index d98a1b84a75..c624dfe476b 100644 --- a/exporter/opentelemetry-exporter-otlp-proto-http/src/opentelemetry/exporter/otlp/proto/http/trace_exporter/__init__.py +++ b/exporter/opentelemetry-exporter-otlp-proto-http/src/opentelemetry/exporter/otlp/proto/http/trace_exporter/__init__.py @@ -101,7 +101,7 @@ 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() @@ -109,7 +109,7 @@ def _export(self, serialized_data: str): 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, diff --git a/exporter/opentelemetry-exporter-zipkin-proto-http/src/opentelemetry/exporter/zipkin/proto/http/v2/__init__.py b/exporter/opentelemetry-exporter-zipkin-proto-http/src/opentelemetry/exporter/zipkin/proto/http/v2/__init__.py index 676c2496f74..308abde01f8 100644 --- a/exporter/opentelemetry-exporter-zipkin-proto-http/src/opentelemetry/exporter/zipkin/proto/http/v2/__init__.py +++ b/exporter/opentelemetry-exporter-zipkin-proto-http/src/opentelemetry/exporter/zipkin/proto/http/v2/__init__.py @@ -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()