Skip to content

Commit 40effae

Browse files
cijothomasutpilla
andauthored
fix: Remove async std (#2820)
Co-authored-by: Utkarsh Umesan Pillai <[email protected]>
1 parent 9569b0f commit 40effae

File tree

9 files changed

+10
-113
lines changed

9 files changed

+10
-113
lines changed

CONTRIBUTING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ It's important to regularly review and remove the `otel_unstable` flag from the
172172

173173
The potential features include:
174174

175-
- Stable and non-experimental features that compliant to specification, and have a feature flag to minimize compilation size. Example: feature flags for signals (like `logs`, `traces`, `metrics`) and runtimes (`rt-tokio`, `rt-tokio-current-thread`, `rt-async-std`).
175+
- Stable and non-experimental features that are compliant with the specification and have a feature flag to minimize compilation size. Example: feature flags for signals (like `logs`, `traces`, `metrics`) and runtimes (`rt-tokio`, `rt-tokio-current-thread`).
176176
- Stable and non-experimental features, although not part of the specification, are crucial for enhancing the tracing/log crate's functionality or boosting performance. These features are also subject to discussion and approval by the OpenTelemetry Rust Maintainers.
177177

178178
All such features should adhere to naming convention `<signal>_<feature_name>`

opentelemetry-otlp/src/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,6 @@
141141
//! ```
142142
//!
143143
//! [`tokio`]: https://tokio.rs
144-
//! [`async-std`]: https://async.rs
145144
//!
146145
//! # Feature Flags
147146
//! The following feature flags can enable exporters for different telemetry signals:

opentelemetry-sdk/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
- **Breaking**: The `Runtime` trait has been simplified and refined. See the [#2641](https://github.com/open-telemetry/opentelemetry-rust/pull/2641)
66
for the changes.
7+
- Removed `async-std` support for `Runtime`, as [`async-std` crate is deprecated](https://crates.io/crates/async-std).
78
- Calls to `MeterProviderBuilder::with_resource`, `TracerProviderBuilder::with_resource`,
89
`LoggerProviderBuilder::with_resource` are now additive ([#2677](https://github.com/open-telemetry/opentelemetry-rust/pull/2677)).
910
- Moved `ExportError` trait from `opentelemetry::trace::ExportError` to `opentelemetry_sdk::export::ExportError`

opentelemetry-sdk/Cargo.toml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ rust-version = "1.75.0"
1212
[dependencies]
1313
opentelemetry = { version = "0.28", path = "../opentelemetry/" }
1414
opentelemetry-http = { version = "0.28", path = "../opentelemetry-http", optional = true }
15-
async-std = { workspace = true, features = ["unstable"], optional = true }
1615
futures-channel = { workspace = true }
1716
futures-executor = { workspace = true }
1817
futures-util = { workspace = true, features = ["std", "sink", "async-await-macro"] }
@@ -47,11 +46,10 @@ jaeger_remote_sampler = ["trace", "opentelemetry-http", "http", "serde", "serde_
4746
logs = ["opentelemetry/logs", "serde_json"]
4847
spec_unstable_logs_enabled = ["logs", "opentelemetry/spec_unstable_logs_enabled"]
4948
metrics = ["opentelemetry/metrics", "glob"]
50-
testing = ["opentelemetry/testing", "trace", "metrics", "logs", "rt-async-std", "rt-tokio", "rt-tokio-current-thread", "tokio/macros", "tokio/rt-multi-thread"]
49+
testing = ["opentelemetry/testing", "trace", "metrics", "logs", "rt-tokio", "rt-tokio-current-thread", "tokio/macros", "tokio/rt-multi-thread"]
5150
experimental_async_runtime = []
5251
rt-tokio = ["tokio", "tokio-stream", "experimental_async_runtime"]
5352
rt-tokio-current-thread = ["tokio", "tokio-stream", "experimental_async_runtime"]
54-
rt-async-std = ["async-std", "experimental_async_runtime"]
5553
internal-logs = ["tracing"]
5654
experimental_metrics_periodicreader_with_async_runtime = ["metrics"]
5755
spec_unstable_metrics_views = ["metrics"]

opentelemetry-sdk/src/lib.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,10 +94,8 @@
9494
//! * `experimental_async_runtime`: Enables the experimental `Runtime` trait and related functionality.
9595
//! * `rt-tokio`: Spawn telemetry tasks using [tokio]'s multi-thread runtime.
9696
//! * `rt-tokio-current-thread`: Spawn telemetry tasks on a separate runtime so that the main runtime won't be blocked.
97-
//! * `rt-async-std`: Spawn telemetry tasks using [async-std]'s runtime.
9897
//!
9998
//! [tokio]: https://crates.io/crates/tokio
100-
//! [async-std]: https://crates.io/crates/async-std
10199
#![warn(
102100
future_incompatible,
103101
missing_debug_implementations,

opentelemetry-sdk/src/runtime.rs

Lines changed: 3 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,18 @@
11
//! Provides an abstraction of several async runtimes
22
//!
3-
//! This allows OpenTelemetry to work with any current or future runtime. There are currently
4-
//! builtin implementations for [Tokio] and [async-std].
3+
//! This allows OpenTelemetry to work with any current or future runtime. There is currently
4+
//! built-in implementation for [Tokio].
55
//!
66
//! [Tokio]: https://crates.io/crates/tokio
7-
//! [async-std]: https://crates.io/crates/async-std
87
98
use futures_util::stream::{unfold, Stream};
109
use std::{fmt::Debug, future::Future, time::Duration};
1110
use thiserror::Error;
1211

13-
/// A runtime is an abstraction of an async runtime like [Tokio] or [async-std]. It allows
12+
/// A runtime is an abstraction of an async runtime like [Tokio]. It allows
1413
/// OpenTelemetry to work with any current and hopefully future runtime implementations.
1514
///
1615
/// [Tokio]: https://crates.io/crates/tokio
17-
/// [async-std]: https://crates.io/crates/async-std
1816
///
1917
/// # Note
2018
///
@@ -139,34 +137,6 @@ impl Runtime for TokioCurrentThread {
139137
}
140138
}
141139

142-
/// Runtime implementation, which works with async-std.
143-
#[cfg(all(feature = "experimental_async_runtime", feature = "rt-async-std"))]
144-
#[cfg_attr(
145-
docsrs,
146-
doc(cfg(all(feature = "experimental_async_runtime", feature = "rt-async-std")))
147-
)]
148-
#[derive(Debug, Clone)]
149-
pub struct AsyncStd;
150-
151-
#[cfg(all(feature = "experimental_async_runtime", feature = "rt-async-std"))]
152-
#[cfg_attr(
153-
docsrs,
154-
doc(cfg(all(feature = "experimental_async_runtime", feature = "rt-async-std")))
155-
)]
156-
impl Runtime for AsyncStd {
157-
fn spawn<F>(&self, future: F)
158-
where
159-
F: Future<Output = ()> + Send + 'static,
160-
{
161-
#[allow(clippy::let_underscore_future)]
162-
let _ = async_std::task::spawn(future);
163-
}
164-
165-
fn delay(&self, duration: Duration) -> impl Future<Output = ()> + Send + 'static {
166-
async_std::task::sleep(duration)
167-
}
168-
}
169-
170140
/// `RuntimeChannel` is an extension to [`Runtime`]. Currently, it provides a
171141
/// channel that is used by the [log] and [span] batch processors.
172142
///
@@ -275,32 +245,3 @@ impl RuntimeChannel for TokioCurrentThread {
275245
)
276246
}
277247
}
278-
279-
#[cfg(all(feature = "experimental_async_runtime", feature = "rt-async-std"))]
280-
impl<T: Send> TrySend for async_std::channel::Sender<T> {
281-
type Message = T;
282-
283-
fn try_send(&self, item: Self::Message) -> Result<(), TrySendError> {
284-
self.try_send(item).map_err(|err| match err {
285-
async_std::channel::TrySendError::Full(_) => TrySendError::ChannelFull,
286-
async_std::channel::TrySendError::Closed(_) => TrySendError::ChannelClosed,
287-
})
288-
}
289-
}
290-
291-
#[cfg(all(feature = "experimental_async_runtime", feature = "rt-async-std"))]
292-
#[cfg_attr(
293-
docsrs,
294-
doc(cfg(all(feature = "experimental_async_runtime", feature = "rt-async-std")))
295-
)]
296-
impl RuntimeChannel for AsyncStd {
297-
type Receiver<T: Debug + Send> = async_std::channel::Receiver<T>;
298-
type Sender<T: Debug + Send> = async_std::channel::Sender<T>;
299-
300-
fn batch_message_channel<T: Debug + Send>(
301-
&self,
302-
capacity: usize,
303-
) -> (Self::Sender<T>, Self::Receiver<T>) {
304-
async_std::channel::bounded(capacity)
305-
}
306-
}

opentelemetry-sdk/src/trace/span_processor_with_async_runtime.rs

Lines changed: 1 addition & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ use std::sync::Arc;
4444
///
4545
/// This processor can be configured with an [`executor`] of your choice to
4646
/// batch and upload spans asynchronously when they end. If you have added a
47-
/// library like [`tokio`] or [`async-std`], you can pass in their respective
47+
/// library like [`tokio`], you can pass in their respective
4848
/// `spawn` and `interval` functions to have batching performed in those
4949
/// contexts.
5050
///
@@ -79,7 +79,6 @@ use std::sync::Arc;
7979
///
8080
/// [`executor`]: https://docs.rs/futures/0.3/futures/executor/index.html
8181
/// [`tokio`]: https://tokio.rs
82-
/// [`async-std`]: https://async.rs
8382
pub struct BatchSpanProcessor<R: RuntimeChannel> {
8483
message_sender: R::Sender<BatchMessage>,
8584

@@ -577,41 +576,4 @@ mod tests {
577576
.unwrap();
578577
runtime.block_on(timeout_test_tokio(false));
579578
}
580-
581-
#[test]
582-
#[cfg(feature = "rt-async-std")]
583-
fn test_timeout_async_std_timeout() {
584-
async_std::task::block_on(timeout_test_std_async(true));
585-
}
586-
587-
#[test]
588-
#[cfg(feature = "rt-async-std")]
589-
fn test_timeout_async_std_not_timeout() {
590-
async_std::task::block_on(timeout_test_std_async(false));
591-
}
592-
593-
// If the time_out is true, then the result suppose to ended with timeout.
594-
// otherwise the exporter should be able to export within time out duration.
595-
#[cfg(feature = "rt-async-std")]
596-
async fn timeout_test_std_async(time_out: bool) {
597-
let config = BatchConfig {
598-
max_export_timeout: Duration::from_millis(if time_out { 5 } else { 60 }),
599-
scheduled_delay: Duration::from_secs(60 * 60 * 24), // set the tick to 24 hours so we know the span must be exported via force_flush
600-
..Default::default()
601-
};
602-
let exporter = BlockingExporter {
603-
delay_for: Duration::from_millis(if !time_out { 5 } else { 60 }),
604-
delay_fn: async_std::task::sleep,
605-
};
606-
let processor = BatchSpanProcessor::new(exporter, config, runtime::AsyncStd);
607-
processor.on_end(new_test_export_span_data());
608-
let flush_res = processor.force_flush();
609-
if time_out {
610-
assert!(flush_res.is_err());
611-
} else {
612-
assert!(flush_res.is_ok());
613-
}
614-
let shutdown_res = processor.shutdown();
615-
assert!(shutdown_res.is_ok());
616-
}
617579
}

opentelemetry-zipkin/README.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,8 @@ fn main() -> Result<(), Box<dyn std::error::Error + Send + Sync + 'static>> {
6565
## Performance
6666

6767
For optimal performance, a batch exporter is recommended as the simple exporter
68-
will export each span synchronously on drop. You can enable the [`rt-tokio`],
69-
[`rt-tokio-current-thread`] or [`rt-async-std`] features and specify a runtime
68+
will export each span synchronously on drop. You can enable the [`rt-tokio`] or
69+
[`rt-tokio-current-thread`] features and specify a runtime
7070
on the pipeline builder to have a batch exporter configured for you
7171
automatically.
7272

@@ -83,7 +83,6 @@ let tracer = opentelemetry_zipkin::new_pipeline()
8383
```
8484

8585
[`rt-tokio`]: https://tokio.rs
86-
[`async-std`]: https://async.rs
8786

8887
## Choosing an HTTP client
8988

opentelemetry/src/trace/mod.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,13 +83,12 @@
8383
//!
8484
//! Exporting spans often involves sending data over a network or performing
8585
//! other I/O tasks. OpenTelemetry allows you to schedule these tasks using
86-
//! whichever runtime you are already using such as [Tokio] or [async-std].
86+
//! whichever runtime you are already using such as [Tokio].
8787
//! When using an async runtime it's best to use the batch span processor
8888
//! where the spans will be sent in batches as opposed to being sent once ended,
8989
//! which often ends up being more efficient.
9090
//!
9191
//! [Tokio]: https://tokio.rs
92-
//! [async-std]: https://async.rs
9392
//!
9493
//! ## Managing Active Spans
9594
//!

0 commit comments

Comments
 (0)