From a55bd1fda6404e5546db235144dc042934e6aea2 Mon Sep 17 00:00:00 2001 From: David Pitoniak Date: Sun, 15 Dec 2024 10:32:49 -0500 Subject: [PATCH] otlp: spawn thread to create blocking reqwest client --- 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(