Skip to content

Commit 3881da6

Browse files
authored
Close channel instead of destroying client
1 parent 9d4e316 commit 3881da6

File tree

1 file changed

+5
-8
lines changed
  • exporter/opentelemetry-exporter-otlp-proto-grpc/src/opentelemetry/exporter/otlp/proto/grpc

1 file changed

+5
-8
lines changed

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

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -243,21 +243,18 @@ def __init__(
243243
) or Compression.NoCompression
244244

245245
if insecure:
246-
self._client = self._stub(
247-
insecure_channel(self._endpoint, compression=compression)
248-
)
246+
self._channel = insecure_channel(self._endpoint, compression=compression)
249247
else:
250248
credentials = _get_credentials(
251249
credentials,
252250
OTEL_EXPORTER_OTLP_CERTIFICATE,
253251
OTEL_EXPORTER_OTLP_CLIENT_KEY,
254252
OTEL_EXPORTER_OTLP_CLIENT_CERTIFICATE,
255253
)
256-
self._client = self._stub(
257-
secure_channel(
258-
self._endpoint, credentials, compression=compression
259-
)
254+
self._channel = secure_channel(
255+
self._endpoint, credentials, compression=compression
260256
)
257+
self._client = self._stub(self._channel)
261258

262259
self._export_lock = threading.Lock()
263260
self._shutdown = False
@@ -360,7 +357,7 @@ def shutdown(self, timeout_millis: float = 30_000, **kwargs) -> None:
360357
# wait for the last export if any
361358
self._export_lock.acquire(timeout=timeout_millis / 1e3)
362359
self._shutdown = True
363-
self._client = None
360+
self._channel.close()
364361
self._export_lock.release()
365362

366363
@property

0 commit comments

Comments
 (0)