Skip to content

Commit ab7bce3

Browse files
authored
chore: cleanup pin-project dep (#830)
* remove pin-project from crates which weren't actually using it * switch to pin-project-lite to improve compilation time and impose fewer deps at consumers (ecosystem migrated to -lite awhile ago tokio-rs/tokio#1778)
1 parent 63b7350 commit ab7bce3

File tree

6 files changed

+26
-24
lines changed

6 files changed

+26
-24
lines changed

opentelemetry-api/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ futures-channel = "0.3"
1010
futures-util = { version = "0.3", default-features = false, features = ["std", "sink"] }
1111
indexmap = "=1.8"
1212
once_cell = "1.12.0"
13-
pin-project = { version = "1.0.2", optional = true }
13+
pin-project-lite = { version = "0.2.9", optional = true }
1414
thiserror = "1"
1515
tokio-stream = { version = "0.1", optional = true }
1616

@@ -23,6 +23,6 @@ js-sys = "0.3"
2323

2424
[features]
2525
default = ["trace"]
26-
trace = ["pin-project"]
26+
trace = ["pin-project-lite"]
2727
metrics = ["fnv"]
2828
testing = ["trace"]

opentelemetry-api/src/trace/context.rs

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use crate::{
66
};
77
use futures_util::{sink::Sink, stream::Stream};
88
use once_cell::sync::Lazy;
9-
use pin_project::pin_project;
9+
use pin_project_lite::pin_project;
1010
use std::{
1111
borrow::Cow,
1212
error::Error,
@@ -351,13 +351,14 @@ where
351351
f(Context::current().span())
352352
}
353353

354-
/// A future, stream, or sink that has an associated context.
355-
#[pin_project]
356-
#[derive(Clone, Debug)]
357-
pub struct WithContext<T> {
358-
#[pin]
359-
inner: T,
360-
otel_cx: Context,
354+
pin_project! {
355+
/// A future, stream, or sink that has an associated context.
356+
#[derive(Clone, Debug)]
357+
pub struct WithContext<T> {
358+
#[pin]
359+
inner: T,
360+
otel_cx: Context,
361+
}
361362
}
362363

363364
impl<T: Sized> FutureExt for T {}

opentelemetry-dynatrace/Cargo.toml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@ wasm = [
4242
"futures-util",
4343
"getrandom/js",
4444
"js-sys",
45-
"pin-project",
4645
"wasm-bindgen",
4746
"wasm-bindgen-futures",
4847
"web-sys",
@@ -59,7 +58,6 @@ isahc = { version = "1.4", default-features = false, optional = true }
5958
js-sys = { version = "0.3.5", optional = true }
6059
opentelemetry = { version = "0.17", path = "../opentelemetry", default-features = false }
6160
opentelemetry-http = { version = "0.6", path = "../opentelemetry-http", default-features = false }
62-
pin-project = { version = "1.0", optional = true }
6361
reqwest = { version = "0.11", default-features = false, optional = true }
6462
surf = { version = "2.0", default-features = false, optional = true }
6563
thiserror = "1.0"

opentelemetry-jaeger/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ once_cell = "1.12"
3333
opentelemetry = { version = "0.17", default-features = false, features = ["trace"], path = "../opentelemetry" }
3434
opentelemetry-http = { version = "0.6", path = "../opentelemetry-http", optional = true }
3535
opentelemetry-semantic-conventions = { version = "0.9", path = "../opentelemetry-semantic-conventions" }
36-
pin-project = { version = "1.0", optional = true }
36+
pin-project-lite = { version = "0.2.9", optional = true }
3737
reqwest = { version = "0.11", default-features = false, optional = true }
3838
surf = { version = "2.0", optional = true }
3939
thiserror = "1.0"
@@ -90,7 +90,7 @@ wasm_collector_client = [
9090
"futures-util",
9191
"http",
9292
"js-sys",
93-
"pin-project",
93+
"pin-project-lite",
9494
"wasm-bindgen",
9595
"wasm-bindgen-futures",
9696
"web-sys",

opentelemetry-jaeger/src/exporter/collector.rs

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ mod wasm_collector_client {
7777
use futures_util::future;
7878
use http::Uri;
7979
use js_sys::Uint8Array;
80+
use pin_project_lite::pin_project;
8081
use std::future::Future;
8182
use std::io::{self, Cursor};
8283
use std::pin::Pin;
@@ -132,7 +133,7 @@ mod wasm_collector_client {
132133
{
133134
self.build_request(batch)
134135
.map(post_request)
135-
.map(|fut| future::Either::Left(SubmitBatchFuture(fut)))
136+
.map(|fut| future::Either::Left(SubmitBatchFuture { fut }))
136137
.unwrap_or_else(|e| future::Either::Right(future::err(e)))
137138
}
138139

@@ -199,19 +200,22 @@ mod wasm_collector_client {
199200
Ok(jaeger::BatchSubmitResponse { ok: true })
200201
}
201202

202-
/// Wrapper of web fetch API future marked as Send.
203-
///
204-
/// At the moment, the web APIs are single threaded. Since all opentelemetry futures are
205-
/// required to be Send, we mark this future as Send.
206-
#[pin_project::pin_project]
207-
struct SubmitBatchFuture<F>(#[pin] F);
203+
pin_project! {
204+
/// Wrapper of web fetch API future marked as Send.
205+
///
206+
/// At the moment, the web APIs are single threaded. Since all opentelemetry futures are
207+
/// required to be Send, we mark this future as Send.
208+
struct SubmitBatchFuture<F> {
209+
#[pin] fut: F
210+
}
211+
}
208212

209213
unsafe impl<F> Send for SubmitBatchFuture<F> {}
210214

211215
impl<F: Future> Future for SubmitBatchFuture<F> {
212216
type Output = F::Output;
213217
fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> {
214-
self.project().0.poll(cx)
218+
self.project().fut.poll(cx)
215219
}
216220
}
217221

opentelemetry-sdk/Cargo.toml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ futures-executor = "0.3"
1717
futures-util = { version = "0.3.17", default-features = false, features = ["std", "sink", "async-await-macro"] }
1818
once_cell = "1.10"
1919
percent-encoding = { version = "2.0", optional = true }
20-
pin-project = { version = "1.0.2", optional = true }
2120
rand = { version = "0.8", default-features = false, features = ["std", "std_rng"], optional = true }
2221
serde = { version = "1.0", features = ["derive", "rc"], optional = true }
2322
serde_json = { version = "1", optional = true }
@@ -38,7 +37,7 @@ rand_distr = "0.4.0"
3837

3938
[features]
4039
default = ["trace"]
41-
trace = ["opentelemetry-api/trace", "crossbeam-channel", "rand", "pin-project", "async-trait", "percent-encoding"]
40+
trace = ["opentelemetry-api/trace", "crossbeam-channel", "rand", "async-trait", "percent-encoding"]
4241
jaeger_remote_sampler = ["trace", "opentelemetry-http", "http", "serde", "serde_json", "url"]
4342
metrics = ["opentelemetry-api/metrics", "dashmap", "fnv"]
4443
testing = ["opentelemetry-api/testing", "trace", "metrics", "rt-async-std", "rt-tokio", "rt-tokio-current-thread", "tokio/macros", "tokio/rt-multi-thread"]

0 commit comments

Comments
 (0)