open-telemetry / opentelemetry-rust

The Rust OpenTelemetry implementation
https://opentelemetry.io
Apache License 2.0
1.89k stars 440 forks source link

[Feature]: Name spawned threads #1949

Open howardjohn opened 4 months ago

howardjohn commented 4 months ago

Related Problems?

No response

Describe the solution you'd like:

The TokioCurrentThread spawns threads without names. This makes debugging hard. For example:

thread '<unnamed>' panicked at /home/john/.rhack/tokio-1.37.0/src/runtime/time/entry.rs:557:9:
A Tokio 1.x context was found, but it is being shutdown.

is quite hard to trace back to otel.

I would like each thread spawned by this library to be named

Considered Alternatives

Use the multithreaded tokio runtime which does not spawn. This is currently causing deadlocks (https://github.com/open-telemetry/opentelemetry-rust/issues/1395), so its not acceptable.

Additional Context

No response

howardjohn commented 4 months ago

BTW, I don't get A Tokio 1.x context was found, but it is being shutdown. after upgrading -- was just an example of a type of issue that would have been easier to debug if the thread was named.

lalitb commented 4 months ago

@howardjohn If you'd like to contribute the fix, please feel free to proceed. We eventually plan to eliminate the dependency on the async runtime for batch processors. I'm currently working on this for logs (#1943), and a similar approach would be replicated to traces as well.

howardjohn commented 3 months ago

BTW turns out the error was actually still happening, opened https://github.com/open-telemetry/opentelemetry-rust/issues/1963. I missed it due to not setting the global trace provider after upgrading :facepalm: