Skip to content

Commit

Permalink
otlp: spawn thread to create blocking reqwest client (#2431)
Browse files Browse the repository at this point in the history
Co-authored-by: Lalit Kumar Bhasin <[email protected]>
  • Loading branch information
pitoniak32 and lalitb authored Dec 17, 2024
1 parent 9cf7a40 commit eb8d7c6
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions opentelemetry-otlp/src/exporter/http/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<dyn HttpClient>);
let default_client = std::thread::spawn(|| {
Some(Arc::new(reqwest::blocking::Client::new()) as Arc<dyn HttpClient>)
})
.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<dyn HttpClient>);
#[cfg(all(
Expand Down

0 comments on commit eb8d7c6

Please sign in to comment.