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

Validate tonic can be used in blocking scenarios/non-tokio context #2402

Open
cijothomas opened this issue Dec 9, 2024 · 1 comment
Open
Milestone

Comments

@cijothomas
Copy link
Member

cijothomas commented Dec 9, 2024

Pre-req to #2386 which proposes to change default to use dedicated thread, and then make blocking calls to networking libraries.

However, tonic requires a tokio runtime to function.
But, based on our testing, it is seen that tonic client captures/stores the tokio runtime at creation time, and subsequently, gRPC methods can be called from non-tokio context as well (i.e from the normal std::thread)
See #2142 (comment)

Have done some tests to validate this behavior in separate repo:
https://github.com/cijothomas/async-explore/blob/main/src/client-no-tokio.rs

This issue is opened to validate that the above is valid, and add integration tests to validate it, and also add doc comments/examples/readme as relevant.

An example content in readme/doc:
When using OTLP with gRPC/tonic, provider(tracer/meter/logger) creation must be done in a tokio runtime, which is required for tonic for function. If your app uses tokio::main, then no further action required. Otherwise, ensure providers are created inside a tokio runtime.
Example: https://github.com/open-telemetry/opentelemetry-rust/tree/main/opentelemetry-otlp/examples/basic-otlp#basic-otlp-exporter-example

@cijothomas cijothomas added this to the 0.28.0 milestone Dec 9, 2024
@cijothomas cijothomas changed the title Validate tonic can be used in blocking scenarios Validate tonic can be used in blocking scenarios/non-tokio context Dec 9, 2024
@cijothomas
Copy link
Member Author

Keeping open until

  1. Another person also tests this manually
  2. Add non tokio::main tests in integration tests

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant