Skip to content

Commit 41bd54b

Browse files
committed
Update test
1 parent 4030ddd commit 41bd54b

File tree

2 files changed

+17
-6
lines changed

2 files changed

+17
-6
lines changed

opentelemetry-zipkin/Cargo.toml

+2-1
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ futures-core = { workspace = true }
4343
[dev-dependencies]
4444
bytes = { workspace = true }
4545
futures-util = { workspace = true, features = ["io"] }
46-
hyper = { workspace = true }
46+
http-body-util = { workspace = true }
47+
hyper-util = { workspace = true, features = ["client-legacy", "http1", "tokio"] }
4748
opentelemetry_sdk = { default-features = false, features = ["trace", "testing"], path = "../opentelemetry-sdk" }
4849
temp-env = { workspace = true }

opentelemetry-zipkin/src/lib.rs

+15-5
Original file line numberDiff line numberDiff line change
@@ -95,28 +95,33 @@
9595
//! use http::{Request, Response};
9696
//! use std::convert::TryInto as _;
9797
//! use std::error::Error;
98-
//! use hyper::{client::HttpConnector, Body};
98+
//! use http_body_util::{BodyExt, Full};
99+
//! use hyper_util::{
100+
//! client::legacy::{Client, connect::HttpConnector},
101+
//! rt::tokio::TokioExecutor,
102+
//! };
99103
//!
100104
//! // `reqwest` is supported through a feature, if you prefer an
101105
//! // alternate http client you can add support by implementing `HttpClient` as
102106
//! // shown here.
103107
//! #[derive(Debug)]
104-
//! struct HyperClient(hyper::Client<HttpConnector, Body>);
108+
//! struct HyperClient(Client<HttpConnector, Full<Bytes>>);
105109
//!
106110
//! #[async_trait]
107111
//! impl HttpClient for HyperClient {
108112
//! async fn send(&self, req: Request<Vec<u8>>) -> Result<Response<Bytes>, HttpError> {
109113
//! let resp = self
110114
//! .0
111-
//! .request(req.map(|v| Body::from(v)))
115+
//! .request(req.map(|v| Full::new(Bytes::from(v))))
112116
//! .await?;
113117
//!
114118
//! let response = Response::builder()
115119
//! .status(resp.status())
116120
//! .body({
117-
//! hyper::body::to_bytes(resp.into_body())
121+
//! resp.collect()
118122
//! .await
119123
//! .expect("cannot decode response")
124+
//! .to_bytes()
120125
//! })
121126
//! .expect("cannot build response");
122127
//!
@@ -127,7 +132,12 @@
127132
//! fn main() -> Result<(), Box<dyn Error + Send + Sync + 'static>> {
128133
//! global::set_text_map_propagator(opentelemetry_zipkin::Propagator::new());
129134
//! let tracer = opentelemetry_zipkin::new_pipeline()
130-
//! .with_http_client(HyperClient(hyper::Client::new()))
135+
//! .with_http_client(
136+
//! HyperClient(
137+
//! Client::builder(TokioExecutor::new())
138+
//! .build_http()
139+
//! )
140+
//! )
131141
//! .with_service_name("my_app")
132142
//! .with_service_address("127.0.0.1:8080".parse()?)
133143
//! .with_collector_endpoint("http://localhost:9411/api/v2/spans")

0 commit comments

Comments
 (0)