Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[gRPC Exporter] gRPC channel is not properly closed #4429

Open
XuanWang-Amos opened this issue Feb 13, 2025 · 1 comment · May be fixed by #4370
Open

[gRPC Exporter] gRPC channel is not properly closed #4429

XuanWang-Amos opened this issue Feb 13, 2025 · 1 comment · May be fixed by #4370
Labels
bug Something isn't working

Comments

@XuanWang-Amos
Copy link

Describe your environment

N/A

What happened?

The gRPC channel is not being closed properly, preventing gRPC from shutting down cleanly.

Steps to Reproduce

Please refer to: grpc/grpc#38490 (comment)

Expected Result

gRPC cleanly shutting down.

Actual Result

gRPC not cleanly shutting down.

Additional context

In OTLPExporterMixin, gRPC channel was created directly and passed to _client:

if insecure:
self._client = self._stub(
insecure_channel(self._endpoint, compression=compression)
)
else:
credentials = _get_credentials(
credentials,
OTEL_EXPORTER_OTLP_CERTIFICATE,
OTEL_EXPORTER_OTLP_CLIENT_KEY,
OTEL_EXPORTER_OTLP_CLIENT_CERTIFICATE,
)
self._client = self._stub(
secure_channel(
self._endpoint, credentials, compression=compression
)
)

But the channel was not shutdown in shutdown method:

def shutdown(self, timeout_millis: float = 30_000, **kwargs) -> None:
if self._shutdown:
logger.warning("Exporter already shutdown, ignoring call")
return
# wait for the last export if any
self._export_lock.acquire(timeout=timeout_millis / 1e3)
self._shutdown = True
self._export_lock.release()

gRPC channel should be closed explicitly with context manager or by calling channel.close() method, example usage:
https://github.com/grpc/grpc/blob/822f9b15191840228d17dc0d305887374150150e/examples/python/helloworld/greeter_client.py#L25-L33

If not explicitly closed, the gRPC channel may prevent gRPC from shutting down cleanly, leading to issues like the one described in: grpc/grpc#38490

Would you like to implement a fix?

None

@xrmx
Copy link
Contributor

xrmx commented Feb 14, 2025

I guess we a PR with the fix already #4370 😅

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants