Skip to content

Commit f6d2a93

Browse files
committed
fix: remove unnecessary thread spawning
1 parent 1d9bd25 commit f6d2a93

File tree

1 file changed

+12
-19
lines changed
  • opentelemetry-otlp/src/exporter/http

1 file changed

+12
-19
lines changed

opentelemetry-otlp/src/exporter/http/mod.rs

Lines changed: 12 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -127,39 +127,32 @@ impl HttpExporterBuilder {
127127
))]
128128
{
129129
// TODO - support configuring custom connector and executor
130-
http_client = Some(Arc::new(HyperClient::with_default_connector(timeout, None))
131-
as Arc<dyn HttpClient>);
130+
let client = HyperClient::with_default_connector(timeout, None);
131+
http_client = Some(Arc::new(client));
132132
}
133133
#[cfg(all(
134134
not(feature = "hyper-client"),
135135
not(feature = "reqwest-blocking-client"),
136136
feature = "reqwest-client"
137137
))]
138138
{
139-
http_client = Some(Arc::new(
140-
reqwest::Client::builder()
141-
.timeout(timeout)
142-
.build()
143-
.unwrap_or_default(),
144-
) as Arc<dyn HttpClient>);
139+
let client = reqwest::Client::builder()
140+
.timeout(timeout)
141+
.build()
142+
.unwrap_or_default();
143+
http_client = Some(Arc::new(client));
145144
}
146145
#[cfg(all(
147146
not(feature = "hyper-client"),
148147
not(feature = "reqwest-client"),
149148
feature = "reqwest-blocking-client"
150149
))]
151150
{
152-
let timeout_clone = timeout;
153-
http_client = Some(Arc::new(
154-
std::thread::spawn(move || {
155-
reqwest::blocking::Client::builder()
156-
.timeout(timeout_clone)
157-
.build()
158-
.unwrap_or_else(|_| reqwest::blocking::Client::new())
159-
})
160-
.join()
161-
.unwrap(), // TODO: Return ExporterBuildError::ThreadSpawnFailed
162-
) as Arc<dyn HttpClient>);
151+
let client = reqwest::blocking::Client::builder()
152+
.timeout(timeout)
153+
.build()
154+
.unwrap_or_default();
155+
http_client = Some(Arc::new(client));
163156
}
164157
}
165158

0 commit comments

Comments
 (0)