Skip to content

Commit

Permalink
chore: cleanup pin-project dep
Browse files Browse the repository at this point in the history
* 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)
  • Loading branch information
matklad committed Jul 1, 2022
1 parent 103ed3a commit 2f6a82a
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 22 deletions.
4 changes: 2 additions & 2 deletions opentelemetry-api/Cargo.toml
Expand Up @@ -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 }

Expand All @@ -23,6 +23,6 @@ js-sys = "0.3"

[features]
default = ["trace"]
trace = ["pin-project"]
trace = ["pin-project-lite"]
metrics = ["fnv"]
testing = ["trace"]
17 changes: 9 additions & 8 deletions opentelemetry-api/src/trace/context.rs
Expand Up @@ -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,
Expand Down Expand Up @@ -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<T> {
#[pin]
inner: T,
otel_cx: Context,
pin_project! {
/// A future, stream, or sink that has an associated context.
#[derive(Clone, Debug)]
pub struct WithContext<T> {
#[pin]
inner: T,
otel_cx: Context,
}
}

impl<T: Sized> FutureExt for T {}
Expand Down
2 changes: 0 additions & 2 deletions opentelemetry-dynatrace/Cargo.toml
Expand Up @@ -42,7 +42,6 @@ wasm = [
"futures-util",
"getrandom/js",
"js-sys",
"pin-project",
"wasm-bindgen",
"wasm-bindgen-futures",
"web-sys",
Expand All @@ -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"
Expand Down
4 changes: 2 additions & 2 deletions opentelemetry-jaeger/Cargo.toml
Expand Up @@ -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", default-features = false, optional = true }
thiserror = "1.0"
Expand Down Expand Up @@ -89,7 +89,7 @@ wasm_collector_client = [
"futures-util",
"http",
"js-sys",
"pin-project",
"pin-project-lite",
"wasm-bindgen",
"wasm-bindgen-futures",
"web-sys",
Expand Down
14 changes: 8 additions & 6 deletions opentelemetry-jaeger/src/exporter/collector.rs
Expand Up @@ -77,6 +77,7 @@ mod wasm_collector_client {
use futures_util::future;
use http::Uri;
use js_sys::Uint8Array;
use pin_project_lit::pin_project;
use std::future::Future;
use std::io::{self, Cursor};
use std::pin::Pin;
Expand Down Expand Up @@ -199,12 +200,13 @@ 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<F>(#[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<F>(#[pin] F);
}

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

Expand Down
3 changes: 1 addition & 2 deletions opentelemetry-sdk/Cargo.toml
Expand Up @@ -16,7 +16,6 @@ futures-util = { version = "0.3", default-features = false, features = ["std", "
once_cell = "1.10"
opentelemetry-api = { version = "0.1", path = "../opentelemetry-api/" }
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 }
thiserror = "1"
Expand All @@ -34,7 +33,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"]
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"]
rt-tokio = ["tokio", "tokio-stream"]
Expand Down

0 comments on commit 2f6a82a

Please sign in to comment.