Skip to content

Commit

Permalink
[Issue open-telemetry#1107] Refactor OTLP exporter to pass compressio…
Browse files Browse the repository at this point in the history
…n value directly rather than through str
  • Loading branch information
wilguo committed Sep 23, 2020
1 parent 6c75f3c commit e2f5b07
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -132,27 +132,20 @@ def __init__(
endpoint: str = "localhost:55680",
credentials: ChannelCredentials = None,
metadata: Optional[Tuple[Any]] = None,
compression: str = None,
compression: Compression = Compression.NoCompression,
):
super().__init__()

self._metadata = metadata
self._collector_span_kwargs = None

if compression == "gzip":
self.compression = Compression.Gzip
else:
self.compression = Compression.NoCompression

if credentials is None:
self._client = self._stub(
insecure_channel(endpoint, compression=self.compression)
insecure_channel(endpoint, compression=compression)
)
else:
self._client = self._stub(
secure_channel(
endpoint, credentials, compression=self.compression
)
secure_channel(endpoint, credentials, compression=compression)
)

@abstractmethod
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,19 +158,6 @@ def setUp(self):
def tearDown(self):
self.server.stop(None)

def test_no_compression(self):
"""Test default compression passed to constructor"""
exporter = OTLPSpanExporter()

self.assertEqual(exporter.compression, Compression.NoCompression)

def test_gzip_compression(self):
"""Test the compression argument passed to constructor."""
compression = "gzip"
exporter = OTLPSpanExporter(compression=compression)

self.assertEqual(exporter.compression, Compression.Gzip)

@patch("opentelemetry.exporter.otlp.exporter.expo")
@patch("opentelemetry.exporter.otlp.exporter.sleep")
def test_unavailable(self, mock_sleep, mock_expo):
Expand Down

0 comments on commit e2f5b07

Please sign in to comment.