Skip to content

Commit 93f206a

Browse files
authored
Remove support for surf HTTP client (#1537)
1 parent d96d59f commit 93f206a

File tree

22 files changed

+19
-183
lines changed

22 files changed

+19
-183
lines changed

Cargo.toml

-1
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,6 @@ rand = "0.8"
5656
reqwest = "0.11"
5757
serde = "1.0"
5858
serde_json = "1.0"
59-
surf = "2.0"
6059
temp-env = "0.3.6"
6160
thiserror = "1"
6261
tonic = "0.11"

opentelemetry-http/CHANGELOG.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44

55
### Changed
66

7+
- **Breaking** Remove built-in support for surf HTTP client [#1537](https://github.com/open-telemetry/opentelemetry-rust/pull/1537)
78
- **Breaking** Surface non-2xx status codes as errors; change `ResponseExt` trait to return `HttpError` instead of `TraceError`[#1484](https://github.com/open-telemetry/opentelemetry-rust/pull/1484)
8-
9-
9+
1010
## v0.10.0
1111

1212
### Changed

opentelemetry-http/Cargo.toml

-1
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,4 @@ hyper = { workspace = true, features = ["http2", "client", "tcp"], optional = tr
1717
isahc = { workspace = true, optional = true }
1818
opentelemetry = { version = "0.21", path = "../opentelemetry", features = ["trace"] }
1919
reqwest = { workspace = true, features = ["blocking"], optional = true }
20-
surf = { workspace = true, optional = true }
2120
tokio = { workspace = true, features = ["time"], optional = true }

opentelemetry-http/src/lib.rs

-60
Original file line numberDiff line numberDiff line change
@@ -100,66 +100,6 @@ mod reqwest {
100100
}
101101
}
102102

103-
#[cfg(feature = "surf")]
104-
pub mod surf {
105-
use std::str::FromStr;
106-
107-
use http::{header::HeaderName, HeaderMap, HeaderValue};
108-
109-
use super::{async_trait, Bytes, HttpClient, HttpError, Request, Response, ResponseExt};
110-
111-
#[derive(Debug)]
112-
pub struct BasicAuthMiddleware(pub surf::http::auth::BasicAuth);
113-
114-
#[async_trait]
115-
impl surf::middleware::Middleware for BasicAuthMiddleware {
116-
async fn handle(
117-
&self,
118-
mut req: surf::Request,
119-
client: surf::Client,
120-
next: surf::middleware::Next<'_>,
121-
) -> surf::Result<surf::Response> {
122-
req.insert_header(self.0.name(), self.0.value());
123-
next.run(req, client).await
124-
}
125-
}
126-
127-
#[async_trait]
128-
impl HttpClient for surf::Client {
129-
async fn send(&self, request: Request<Vec<u8>>) -> Result<Response<Bytes>, HttpError> {
130-
let (parts, body) = request.into_parts();
131-
let method = parts.method.as_str().parse()?;
132-
let uri = parts.uri.to_string().parse()?;
133-
134-
let mut request_builder = surf::Request::builder(method, uri).body(body);
135-
let mut prev_name = None;
136-
for (new_name, value) in parts.headers.into_iter() {
137-
let name = new_name.or(prev_name).expect("the first time new_name should be set and from then on we always have a prev_name");
138-
request_builder = request_builder.header(name.as_str(), value.to_str()?);
139-
prev_name = Some(name);
140-
}
141-
142-
let mut response = self.send(request_builder).await?;
143-
let mut headers = HeaderMap::new();
144-
for header_name in response.header_names() {
145-
for header_value in &response[header_name.to_string().as_str()] {
146-
headers.append(
147-
HeaderName::from_str(&header_name.to_string())?,
148-
HeaderValue::from_str(header_value.as_str())?,
149-
);
150-
}
151-
}
152-
let mut http_response = Response::builder()
153-
.status(response.status() as u16)
154-
.body(response.body_bytes().await?.into())?;
155-
156-
*http_response.headers_mut() = headers;
157-
158-
Ok(http_response.error_for_status()?)
159-
}
160-
}
161-
}
162-
163103
#[cfg(feature = "isahc")]
164104
mod isahc {
165105
use crate::ResponseExt;

opentelemetry-jaeger/CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
### Changed
66

7+
- **Breaking** Remove support for surf HTTP client [#1537](https://github.com/open-telemetry/opentelemetry-rust/pull/1537)
78
- Update to tonic 0.11 and prost 0.12 (#1536)
89

910
## v0.21.0

opentelemetry-jaeger/Cargo.toml

+1-4
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ opentelemetry-http = { version = "0.10", path = "../opentelemetry-http", optiona
3535
opentelemetry-semantic-conventions = { version = "0.13", path = "../opentelemetry-semantic-conventions" }
3636
pin-project-lite = { workspace = true, optional = true }
3737
reqwest = { workspace = true, optional = true }
38-
surf = { workspace = true, optional = true }
3938
thrift = "0.17.0"
4039
tokio = { workspace = true, features = ["net", "sync"], optional = true }
4140
wasm-bindgen = { version = "0.2", optional = true }
@@ -79,7 +78,6 @@ full = [
7978
"reqwest_collector_client",
8079
"reqwest_blocking_collector_client",
8180
"reqwest_rustls_collector_client",
82-
"surf_collector_client",
8381
"wasm_collector_client",
8482
"rt-tokio",
8583
"rt-tokio-current-thread",
@@ -94,7 +92,6 @@ isahc_collector_client = ["isahc", "opentelemetry-http/isahc"]
9492
reqwest_blocking_collector_client = ["reqwest/blocking", "collector_client", "headers", "opentelemetry-http/reqwest"]
9593
reqwest_collector_client = ["reqwest", "collector_client", "headers", "opentelemetry-http/reqwest"]
9694
reqwest_rustls_collector_client = ["reqwest_collector_client", "reqwest/rustls-tls-native-roots"]
97-
surf_collector_client = ["surf", "collector_client", "opentelemetry-http/surf"]
9895
wasm_collector_client = [
9996
"base64",
10097
"http",
@@ -107,4 +104,4 @@ wasm_collector_client = [
107104
rt-tokio = ["tokio", "opentelemetry_sdk/rt-tokio"]
108105
rt-tokio-current-thread = ["tokio", "opentelemetry_sdk/rt-tokio-current-thread"]
109106
rt-async-std = ["async-std", "opentelemetry_sdk/rt-async-std"]
110-
integration_test = ["tonic", "prost", "prost-types", "rt-tokio", "collector_client", "hyper_collector_client", "hyper_tls_collector_client", "reqwest_collector_client", "surf_collector_client", "isahc_collector_client"]
107+
integration_test = ["tonic", "prost", "prost-types", "rt-tokio", "collector_client", "hyper_collector_client", "hyper_tls_collector_client", "reqwest_collector_client", "isahc_collector_client"]

opentelemetry-jaeger/README.md

-1
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,6 @@ Then you can use the [`with_collector_endpoint`] method to specify the endpoint:
113113
```rust
114114
// Note that this requires one of the following features enabled so that there is a default http client implementation
115115
// * hyper_collector_client
116-
// * surf_collector_client
117116
// * reqwest_collector_client
118117
// * reqwest_blocking_collector_client
119118
// * reqwest_rustls_collector_client

opentelemetry-jaeger/src/exporter/config/collector/http_client.rs

-26
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@ pub(crate) enum CollectorHttpClient {
99
Hyper,
1010
#[cfg(feature = "isahc_collector_client")]
1111
Isahc,
12-
#[cfg(feature = "surf_collector_client")]
13-
Surf,
1412
#[cfg(feature = "reqwest_collector_client")]
1513
Reqwest,
1614
#[cfg(feature = "reqwest_blocking_collector_client")]
@@ -57,30 +55,6 @@ impl CollectorHttpClient {
5755
})?;
5856
Ok(Box::new(client))
5957
}
60-
#[cfg(feature = "surf_collector_client")]
61-
CollectorHttpClient::Surf => {
62-
use opentelemetry_http::surf::BasicAuthMiddleware;
63-
64-
let client: surf::Client = surf::Config::new()
65-
.set_timeout(Some(collector_timeout))
66-
.try_into()
67-
.map_err(|err| crate::Error::ConfigError {
68-
pipeline_name: "collector",
69-
config_name: "http_client",
70-
reason: format!("cannot create surf client. {}", err),
71-
})?;
72-
73-
let client = if let (Some(username), Some(password)) =
74-
(collector_username, collector_password)
75-
{
76-
let auth = surf::http::auth::BasicAuth::new(username, password);
77-
client.with(BasicAuthMiddleware(auth))
78-
} else {
79-
client
80-
};
81-
82-
Ok(Box::new(client))
83-
}
8458
#[cfg(feature = "reqwest_blocking_collector_client")]
8559
CollectorHttpClient::ReqwestBlocking => {
8660
use headers::authorization::Credentials;

opentelemetry-jaeger/src/exporter/config/collector/mod.rs

+1-13
Original file line numberDiff line numberDiff line change
@@ -65,10 +65,9 @@ const ENV_PASSWORD: &str = "OTEL_EXPORTER_JAEGER_PASSWORD";
6565
/// implementation and relative configurations.
6666
///
6767
/// - [hyper], requires `hyper_collector_client` feature enabled, use [`with_hyper`][CollectorPipeline::with_hyper] function to setup.
68-
/// - [surf], requires `surf_collector_client` feature enabled, use [`with_surf`][CollectorPipeline::with_surf] function to setup.
6968
/// - [isahc], requires `isahc_collector_client` feature enabled, use [`with_isahc`][CollectorPipeline::with_isahc] function to setup.
7069
/// - [reqwest], requires `reqwest_collector_client` feature enabled, use [`with_reqwest`][CollectorPipeline::with_reqwest] function to setup.
71-
/// - [reqwest blocking client], requires `reqwest_blocking_collector_client` feature enabled, use [`with_reqwest_blocking`][CollectorPipeline::with_surf] function to setup.
70+
/// - [reqwest blocking client], requires `reqwest_blocking_collector_client` feature enabled, use [`with_reqwest_blocking`][CollectorPipeline::with_reqwest_blocking] function to setup.
7271
///
7372
/// Additionally you can enable https
7473
///
@@ -277,17 +276,6 @@ impl CollectorPipeline {
277276
}
278277
}
279278

280-
/// Use surf http client in the exporter.
281-
#[cfg(feature = "surf_collector_client")]
282-
pub fn with_surf(self) -> Self {
283-
Self {
284-
client_config: ClientConfig::Http {
285-
client_type: CollectorHttpClient::Surf,
286-
},
287-
..self
288-
}
289-
}
290-
291279
/// Use reqwest http client in the exporter.
292280
#[cfg(feature = "reqwest_collector_client")]
293281
pub fn with_reqwest(self) -> Self {

opentelemetry-jaeger/src/exporter/mod.rs

-2
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22
//!
33
// Linting isn't detecting that it's used seems like linting bug.
44
#[allow(unused_imports)]
5-
#[cfg(feature = "surf_collector_client")]
6-
use std::convert::TryFrom;
75
use std::convert::TryInto;
86
use std::fmt::Display;
97
use std::net::{Ipv4Addr, Ipv6Addr, SocketAddr};

opentelemetry-jaeger/src/lib.rs

-5
Original file line numberDiff line numberDiff line change
@@ -232,9 +232,6 @@
232232
//! .with_resource(Resource::new(vec![KeyValue::new("key", "value"),
233233
//! KeyValue::new("process_key", "process_value")])),
234234
//! )
235-
//! // we config a surf http client with 2 seconds timeout
236-
//! // and have basic authentication header with username=username, password=s3cr3t
237-
//! .with_isahc() // requires `isahc_collector_client` feature
238235
//! .with_username("username")
239236
//! .with_password("s3cr3t")
240237
//! .with_timeout(std::time::Duration::from_secs(2))
@@ -259,8 +256,6 @@
259256
//!
260257
//! * `hyper_collector_client`: Export span data with Jaeger collector backed by a hyper default http client.
261258
//!
262-
//! * `surf_collector_client`: Export span data with Jaeger collector backed by a surf default http client.
263-
//!
264259
//! * `reqwest_collector_client`: Export span data with Jaeger collector backed by a reqwest http client.
265260
//!
266261
//! * `reqwest_blocking_collector_client`: Export span data with Jaeger collector backed by a reqwest blocking http client.

opentelemetry-jaeger/tests/integration_test.rs

-11
Original file line numberDiff line numberDiff line change
@@ -101,17 +101,6 @@ mod tests {
101101
.expect("cannot create tracer using default configuration")
102102
}),
103103
),
104-
(
105-
"collector_surf",
106-
Box::new(|| {
107-
opentelemetry_jaeger::new_collector_pipeline()
108-
.with_endpoint(collector_endpoint)
109-
.with_surf()
110-
.with_service_name(format!("{}-{}", SERVICE_NAME, "collector_surf"))
111-
.install_batch(opentelemetry_sdk::runtime::Tokio)
112-
.expect("cannot create tracer using default configuration")
113-
}),
114-
),
115104
(
116105
"collector_hyper",
117106
Box::new(|| {

opentelemetry-otlp/CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
## vNext
44

5+
- **Breaking** Remove support for surf HTTP client [#1537](https://github.com/open-telemetry/opentelemetry-rust/pull/1537)
56
- Update to tonic 0.11 and prost 0.12 (#1536)
67
- Remove support for grpcio transport (#1534)
78

opentelemetry-otlp/Cargo.toml

-2
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ tonic = { workspace = true, optional = true }
3939
tokio = { workspace = true, features = ["sync", "rt"], optional = true }
4040

4141
reqwest = { workspace = true, optional = true }
42-
surf = { workspace = true, optional = true }
4342
http = { workspace = true, optional = true }
4443
serde = { workspace = true, features = ["derive"], optional = true }
4544
thiserror = { workspace = true }
@@ -74,7 +73,6 @@ http-proto = ["prost", "opentelemetry-http", "opentelemetry-proto/gen-tonic-mess
7473
reqwest-blocking-client = ["reqwest/blocking", "opentelemetry-http/reqwest"]
7574
reqwest-client = ["reqwest", "opentelemetry-http/reqwest"]
7675
reqwest-rustls = ["reqwest", "reqwest/rustls-tls-native-roots"]
77-
surf-client = ["surf", "opentelemetry-http/surf"]
7876

7977
# test
8078
integration-testing = ["tonic", "prost", "tokio/full", "trace"]

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

+2-18
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ mod trace;
2727
#[cfg_attr(
2828
all(
2929
not(feature = "reqwest-client"),
30-
not(feature = "surf-client"),
3130
not(feature = "reqwest-blocking-client")
3231
),
3332
derive(Default)
@@ -40,31 +39,16 @@ pub(crate) struct HttpConfig {
4039
headers: Option<HashMap<String, String>>,
4140
}
4241

43-
#[cfg(any(
44-
feature = "reqwest-blocking-client",
45-
feature = "reqwest-client",
46-
feature = "surf-client"
47-
))]
42+
#[cfg(any(feature = "reqwest-blocking-client", feature = "reqwest-client",))]
4843
impl Default for HttpConfig {
4944
fn default() -> Self {
5045
HttpConfig {
5146
#[cfg(feature = "reqwest-blocking-client")]
5247
client: Some(Arc::new(reqwest::blocking::Client::new())),
53-
#[cfg(all(
54-
not(feature = "reqwest-blocking-client"),
55-
not(feature = "surf-client"),
56-
feature = "reqwest-client"
57-
))]
48+
#[cfg(all(not(feature = "reqwest-blocking-client"), feature = "reqwest-client"))]
5849
client: Some(Arc::new(reqwest::Client::new())),
5950
#[cfg(all(
6051
not(feature = "reqwest-client"),
61-
not(feature = "reqwest-blocking-client"),
62-
feature = "surf-client"
63-
))]
64-
client: Some(Arc::new(surf::Client::new())),
65-
#[cfg(all(
66-
not(feature = "reqwest-client"),
67-
not(feature = "surf-client"),
6852
not(feature = "reqwest-blocking-client")
6953
))]
7054
client: None,

opentelemetry-otlp/src/lib.rs

-2
Original file line numberDiff line numberDiff line change
@@ -104,8 +104,6 @@
104104
//! * `reqwest-blocking-client`: Use reqwest blocking http client.
105105
//! * `reqwest-client`: Use reqwest http client.
106106
//! * `reqwest-rustls`: Use reqwest with TLS.
107-
//! * `surf-client`: Use surf http client.
108-
//!
109107
//!
110108
//! # Kitchen Sink Full Configuration
111109
//!

opentelemetry-zipkin/CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22

33
## vNext
44

5+
### Changed
6+
7+
- **Breaking** Remove support for surf HTTP client [#1537](https://github.com/open-telemetry/opentelemetry-rust/pull/1537)
8+
59
## v0.19.0
610

711
### Changed

opentelemetry-zipkin/Cargo.toml

-2
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ default = ["reqwest-blocking-client", "reqwest/native-tls"]
2424
reqwest-blocking-client = ["reqwest/blocking", "opentelemetry-http/reqwest"]
2525
reqwest-client = ["reqwest", "opentelemetry-http/reqwest"]
2626
reqwest-rustls = ["reqwest", "reqwest/rustls-tls-native-roots"]
27-
surf-client = ["surf", "opentelemetry-http/surf"]
2827

2928
[dependencies]
3029
async-trait = { workspace = true }
@@ -38,7 +37,6 @@ serde = { workspace = true, features = ["derive"] }
3837
typed-builder = "0.12"
3938
http = { workspace = true }
4039
reqwest = { workspace = true, optional = true}
41-
surf = { workspace = true, optional = true}
4240
thiserror = { workspace = true }
4341
futures-core = { workspace = true }
4442

opentelemetry-zipkin/README.md

+3-4
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ fn main() -> Result<(), Box<dyn std::error::Error + Send + Sync + 'static>> {
5050
tracer.in_span("doing_work", |cx| {
5151
// Traced app logic here...
5252
});
53-
53+
5454
global::shutdown_tracer_provider();
5555

5656
Ok(())
@@ -86,9 +86,8 @@ a manual implementation of the [`HttpClient`] trait. By default the
8686
`reqwest-blocking-client` feature is enabled which will use the `reqwest` crate.
8787
While this is compatible with both async and non-async projects, it is not
8888
optimal for high-performance async applications as it will block the executor
89-
thread. Consider using the `reqwest-client` (without blocking) or `surf-client`
90-
features if you are in the `tokio` or `async-std` ecosystems respectively, or
91-
select whichever client you prefer as shown below.
89+
thread. Consider using the `reqwest-client` (without blocking) if you are in
90+
the `tokio` ecosystem.
9291

9392
Note that async http clients may require a specific async runtime to be
9493
available so be sure to match them appropriately.

0 commit comments

Comments
 (0)