From eb8d7c69ce5860948c68b33fc0e240c1aab012d0 Mon Sep 17 00:00:00 2001 From: David Pitoniak <84917393+pitoniak32@users.noreply.github.com> Date: Tue, 17 Dec 2024 09:59:02 -0500 Subject: [PATCH] otlp: spawn thread to create blocking reqwest client (#2431) Co-authored-by: Lalit Kumar Bhasin --- opentelemetry-otlp/src/exporter/http/mod.rs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/opentelemetry-otlp/src/exporter/http/mod.rs b/opentelemetry-otlp/src/exporter/http/mod.rs index da6c280a61..e718960686 100644 --- a/opentelemetry-otlp/src/exporter/http/mod.rs +++ b/opentelemetry-otlp/src/exporter/http/mod.rs @@ -66,8 +66,11 @@ pub struct HttpConfig { impl Default for HttpConfig { fn default() -> Self { #[cfg(feature = "reqwest-blocking-client")] - let default_client = - Some(Arc::new(reqwest::blocking::Client::new()) as Arc); + let default_client = std::thread::spawn(|| { + Some(Arc::new(reqwest::blocking::Client::new()) as Arc) + }) + .join() + .expect("creating reqwest::blocking::Client on a new thread not to fail"); #[cfg(all(not(feature = "reqwest-blocking-client"), feature = "reqwest-client"))] let default_client = Some(Arc::new(reqwest::Client::new()) as Arc); #[cfg(all(