Skip to content

Commit e2f5b07

Browse files
committed
[Issue open-telemetry#1107] Refactor OTLP exporter to pass compression value directly rather than through str
1 parent 6c75f3c commit e2f5b07

File tree

2 files changed

+3
-23
lines changed

2 files changed

+3
-23
lines changed

exporter/opentelemetry-exporter-otlp/src/opentelemetry/exporter/otlp/exporter.py

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -132,27 +132,20 @@ def __init__(
132132
endpoint: str = "localhost:55680",
133133
credentials: ChannelCredentials = None,
134134
metadata: Optional[Tuple[Any]] = None,
135-
compression: str = None,
135+
compression: Compression = Compression.NoCompression,
136136
):
137137
super().__init__()
138138

139139
self._metadata = metadata
140140
self._collector_span_kwargs = None
141141

142-
if compression == "gzip":
143-
self.compression = Compression.Gzip
144-
else:
145-
self.compression = Compression.NoCompression
146-
147142
if credentials is None:
148143
self._client = self._stub(
149-
insecure_channel(endpoint, compression=self.compression)
144+
insecure_channel(endpoint, compression=compression)
150145
)
151146
else:
152147
self._client = self._stub(
153-
secure_channel(
154-
endpoint, credentials, compression=self.compression
155-
)
148+
secure_channel(endpoint, credentials, compression=compression)
156149
)
157150

158151
@abstractmethod

exporter/opentelemetry-exporter-otlp/tests/test_otlp_trace_exporter.py

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -158,19 +158,6 @@ def setUp(self):
158158
def tearDown(self):
159159
self.server.stop(None)
160160

161-
def test_no_compression(self):
162-
"""Test default compression passed to constructor"""
163-
exporter = OTLPSpanExporter()
164-
165-
self.assertEqual(exporter.compression, Compression.NoCompression)
166-
167-
def test_gzip_compression(self):
168-
"""Test the compression argument passed to constructor."""
169-
compression = "gzip"
170-
exporter = OTLPSpanExporter(compression=compression)
171-
172-
self.assertEqual(exporter.compression, Compression.Gzip)
173-
174161
@patch("opentelemetry.exporter.otlp.exporter.expo")
175162
@patch("opentelemetry.exporter.otlp.exporter.sleep")
176163
def test_unavailable(self, mock_sleep, mock_expo):

0 commit comments

Comments
 (0)