diff --git a/opentelemetry-api/Cargo.toml b/opentelemetry-api/Cargo.toml index 76deaf3fa3..bbed1957da 100644 --- a/opentelemetry-api/Cargo.toml +++ b/opentelemetry-api/Cargo.toml @@ -10,7 +10,7 @@ futures-channel = "0.3" futures-util = { version = "0.3", default-features = false, features = ["std", "sink"] } indexmap = "=1.8" once_cell = "1.12.0" -pin-project = { version = "1.0.2", optional = true } +pin-project-lite = { version = "0.2.9", optional = true } thiserror = "1" tokio-stream = { version = "0.1", optional = true } @@ -23,6 +23,6 @@ js-sys = "0.3" [features] default = ["trace"] -trace = ["pin-project"] +trace = ["pin-project-lite"] metrics = ["fnv"] testing = ["trace"] diff --git a/opentelemetry-api/src/trace/context.rs b/opentelemetry-api/src/trace/context.rs index 9d8f047f21..60aad31fdd 100644 --- a/opentelemetry-api/src/trace/context.rs +++ b/opentelemetry-api/src/trace/context.rs @@ -6,7 +6,7 @@ use crate::{ }; use futures_util::{sink::Sink, stream::Stream}; use once_cell::sync::Lazy; -use pin_project::pin_project; +use pin_project_lite::pin_project; use std::{ borrow::Cow, error::Error, @@ -351,13 +351,14 @@ where f(Context::current().span()) } -/// A future, stream, or sink that has an associated context. -#[pin_project] -#[derive(Clone, Debug)] -pub struct WithContext { - #[pin] - inner: T, - otel_cx: Context, +pin_project! { + /// A future, stream, or sink that has an associated context. + #[derive(Clone, Debug)] + pub struct WithContext { + #[pin] + inner: T, + otel_cx: Context, + } } impl FutureExt for T {} diff --git a/opentelemetry-dynatrace/Cargo.toml b/opentelemetry-dynatrace/Cargo.toml index a5b122b408..4a7c9cb307 100644 --- a/opentelemetry-dynatrace/Cargo.toml +++ b/opentelemetry-dynatrace/Cargo.toml @@ -42,7 +42,6 @@ wasm = [ "futures-util", "getrandom/js", "js-sys", - "pin-project", "wasm-bindgen", "wasm-bindgen-futures", "web-sys", @@ -59,7 +58,6 @@ isahc = { version = "1.4", default-features = false, optional = true } js-sys = { version = "0.3.5", optional = true } opentelemetry = { version = "0.17", path = "../opentelemetry", default-features = false } opentelemetry-http = { version = "0.6", path = "../opentelemetry-http", default-features = false } -pin-project = { version = "1.0", optional = true } reqwest = { version = "0.11", default-features = false, optional = true } surf = { version = "2.0", default-features = false, optional = true } thiserror = "1.0" diff --git a/opentelemetry-jaeger/Cargo.toml b/opentelemetry-jaeger/Cargo.toml index e80ae7be60..787dd9730f 100644 --- a/opentelemetry-jaeger/Cargo.toml +++ b/opentelemetry-jaeger/Cargo.toml @@ -33,7 +33,7 @@ once_cell = "1.12" opentelemetry = { version = "0.17", default-features = false, features = ["trace"], path = "../opentelemetry" } opentelemetry-http = { version = "0.6", path = "../opentelemetry-http", optional = true } opentelemetry-semantic-conventions = { version = "0.9", path = "../opentelemetry-semantic-conventions" } -pin-project = { version = "1.0", optional = true } +pin-project-lite = { version = "0.2.9", optional = true } reqwest = { version = "0.11", default-features = false, optional = true } surf = { version = "2.0", optional = true } thiserror = "1.0" @@ -90,7 +90,7 @@ wasm_collector_client = [ "futures-util", "http", "js-sys", - "pin-project", + "pin-project-lite", "wasm-bindgen", "wasm-bindgen-futures", "web-sys", diff --git a/opentelemetry-jaeger/src/exporter/collector.rs b/opentelemetry-jaeger/src/exporter/collector.rs index 3c483d81a3..9e10a42f46 100644 --- a/opentelemetry-jaeger/src/exporter/collector.rs +++ b/opentelemetry-jaeger/src/exporter/collector.rs @@ -77,6 +77,7 @@ mod wasm_collector_client { use futures_util::future; use http::Uri; use js_sys::Uint8Array; + use pin_project_lite::pin_project; use std::future::Future; use std::io::{self, Cursor}; use std::pin::Pin; @@ -132,7 +133,7 @@ mod wasm_collector_client { { self.build_request(batch) .map(post_request) - .map(|fut| future::Either::Left(SubmitBatchFuture(fut))) + .map(|fut| future::Either::Left(SubmitBatchFuture { fut })) .unwrap_or_else(|e| future::Either::Right(future::err(e))) } @@ -199,19 +200,22 @@ mod wasm_collector_client { Ok(jaeger::BatchSubmitResponse { ok: true }) } - /// Wrapper of web fetch API future marked as Send. - /// - /// At the moment, the web APIs are single threaded. Since all opentelemetry futures are - /// required to be Send, we mark this future as Send. - #[pin_project::pin_project] - struct SubmitBatchFuture(#[pin] F); + pin_project! { + /// Wrapper of web fetch API future marked as Send. + /// + /// At the moment, the web APIs are single threaded. Since all opentelemetry futures are + /// required to be Send, we mark this future as Send. + struct SubmitBatchFuture { + #[pin] fut: F + } + } unsafe impl Send for SubmitBatchFuture {} impl Future for SubmitBatchFuture { type Output = F::Output; fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll { - self.project().0.poll(cx) + self.project().fut.poll(cx) } } diff --git a/opentelemetry-sdk/Cargo.toml b/opentelemetry-sdk/Cargo.toml index b2e0c31eb6..7f4fcfa758 100644 --- a/opentelemetry-sdk/Cargo.toml +++ b/opentelemetry-sdk/Cargo.toml @@ -17,7 +17,6 @@ futures-executor = "0.3" futures-util = { version = "0.3.17", default-features = false, features = ["std", "sink", "async-await-macro"] } once_cell = "1.10" percent-encoding = { version = "2.0", optional = true } -pin-project = { version = "1.0.2", optional = true } rand = { version = "0.8", default-features = false, features = ["std", "std_rng"], optional = true } serde = { version = "1.0", features = ["derive", "rc"], optional = true } serde_json = { version = "1", optional = true } @@ -38,7 +37,7 @@ rand_distr = "0.4.0" [features] default = ["trace"] -trace = ["opentelemetry-api/trace", "crossbeam-channel", "rand", "pin-project", "async-trait", "percent-encoding"] +trace = ["opentelemetry-api/trace", "crossbeam-channel", "rand", "async-trait", "percent-encoding"] jaeger_remote_sampler = ["trace", "opentelemetry-http", "http", "serde", "serde_json", "url"] metrics = ["opentelemetry-api/metrics", "dashmap", "fnv"] testing = ["opentelemetry-api/testing", "trace", "metrics", "rt-async-std", "rt-tokio", "rt-tokio-current-thread", "tokio/macros", "tokio/rt-multi-thread"]