Skip to content

Commit d91b847

Browse files
authored
chore(sdk): remove tokio runtime from testing feature (#3407)
1 parent 05bdb98 commit d91b847

File tree

5 files changed

+14
-9
lines changed

5 files changed

+14
-9
lines changed

opentelemetry-appender-log/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ experimental_metadata_attributes = ["dep:opentelemetry-semantic-conventions"]
2828
opentelemetry_sdk = { workspace = true, features = ["testing"] }
2929
opentelemetry-stdout = { workspace = true, features = ["logs"] }
3030
log = { workspace = true, features = ["kv_serde"] }
31-
tokio = { workspace = true }
31+
tokio = { workspace = true, features = ["macros", "rt-multi-thread"] }
3232
serde = { workspace = true, features = ["std", "derive"] }
3333

3434
[lints]

opentelemetry-sdk/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22

33
## vNext
44

5+
- **Breaking** The SDK `testing` feature is now runtime agnostic. [#3407][3407]
6+
- `TokioSpanExporter` and `new_tokio_test_exporter` have been renamed to `TestSpanExporter` and `new_test_exporter`.
7+
- The following transitive dependencies and features have been removed: `tokio/rt`, `tokio/time`, `tokio/macros`, `tokio/rt-multi-thread`, `tokio-stream`, `experimental_async_runtime`
58
- Add 32-bit platform support by using `portable-atomic` for `AtomicI64` and `AtomicU64` in the metrics module. This enables compilation on 32-bit ARM targets (e.g., `armv5te-unknown-linux-gnueabi`, `armv7-unknown-linux-gnueabihf`).
69
- `Aggregation` enum and `StreamBuilder::with_aggregation()` are now stable and no longer require the `spec_unstable_metrics_views` feature flag.
710
- Fix `service.name` Resource attribute fallback to follow OpenTelemetry
@@ -29,6 +32,7 @@
2932
[3312]: https://github.com/open-telemetry/opentelemetry-rust/pull/3312
3033
[3248]: https://github.com/open-telemetry/opentelemetry-rust/pull/3248
3134
[3262]: https://github.com/open-telemetry/opentelemetry-rust/pull/3262
35+
[3407]: https://github.com/open-telemetry/opentelemetry-rust/pull/3407
3236

3337
- "spec_unstable_logs_enabled" feature flag is removed. The capability (and the
3438
backing specification) is now stable and is enabled by default.

opentelemetry-sdk/Cargo.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ rustdoc-args = ["--cfg", "docsrs"]
3737
criterion = { workspace = true, features = ["html_reports"] }
3838
rstest = { workspace = true }
3939
temp-env = { workspace = true }
40+
tokio = { workspace = true, features = ["macros", "rt-multi-thread"] }
4041

4142
[target.'cfg(not(target_os = "windows"))'.dev-dependencies]
4243
pprof = { workspace = true }
@@ -47,7 +48,7 @@ trace = ["opentelemetry/trace", "rand", "percent-encoding"]
4748
jaeger_remote_sampler = ["trace", "opentelemetry-http", "http", "serde", "serde_json", "url", "experimental_async_runtime"]
4849
logs = ["opentelemetry/logs"]
4950
metrics = ["opentelemetry/metrics"]
50-
testing = ["opentelemetry/testing", "trace", "metrics", "logs", "rt-tokio", "rt-tokio-current-thread", "tokio/macros", "tokio/rt-multi-thread"]
51+
testing = ["opentelemetry/testing", "trace", "metrics", "logs", "tokio/sync"]
5152
experimental_async_runtime = []
5253
rt-tokio = ["tokio/rt", "tokio/time", "tokio-stream", "experimental_async_runtime"]
5354
rt-tokio-current-thread = ["tokio/rt", "tokio/time", "tokio-stream", "experimental_async_runtime"]

opentelemetry-sdk/src/testing/trace/span_exporters.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,12 @@ pub fn new_test_export_span_data() -> SpanData {
3636
}
3737

3838
#[derive(Debug)]
39-
pub struct TokioSpanExporter {
39+
pub struct TestSpanExporter {
4040
tx_export: tokio::sync::mpsc::UnboundedSender<SpanData>,
4141
tx_shutdown: tokio::sync::mpsc::UnboundedSender<()>,
4242
}
4343

44-
impl SpanExporter for TokioSpanExporter {
44+
impl SpanExporter for TestSpanExporter {
4545
async fn export(&self, batch: Vec<SpanData>) -> OTelSdkResult {
4646
batch.into_iter().try_for_each(|span_data| {
4747
self.tx_export
@@ -57,14 +57,14 @@ impl SpanExporter for TokioSpanExporter {
5757
}
5858
}
5959

60-
pub fn new_tokio_test_exporter() -> (
61-
TokioSpanExporter,
60+
pub fn new_test_exporter() -> (
61+
TestSpanExporter,
6262
tokio::sync::mpsc::UnboundedReceiver<SpanData>,
6363
tokio::sync::mpsc::UnboundedReceiver<()>,
6464
) {
6565
let (tx_export, rx_export) = tokio::sync::mpsc::unbounded_channel();
6666
let (tx_shutdown, rx_shutdown) = tokio::sync::mpsc::unbounded_channel();
67-
let exporter = TokioSpanExporter {
67+
let exporter = TestSpanExporter {
6868
tx_export,
6969
tx_shutdown,
7070
};

opentelemetry-sdk/src/trace/span_processor_with_async_runtime.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -449,7 +449,7 @@ mod tests {
449449
use super::{BatchSpanProcessor, SpanProcessor};
450450
use crate::error::OTelSdkResult;
451451
use crate::runtime;
452-
use crate::testing::trace::{new_test_export_span_data, new_tokio_test_exporter};
452+
use crate::testing::trace::{new_test_export_span_data, new_test_exporter};
453453
use crate::trace::span_processor::{
454454
OTEL_BSP_EXPORT_TIMEOUT, OTEL_BSP_MAX_EXPORT_BATCH_SIZE, OTEL_BSP_MAX_QUEUE_SIZE,
455455
OTEL_BSP_MAX_QUEUE_SIZE_DEFAULT, OTEL_BSP_SCHEDULE_DELAY, OTEL_BSP_SCHEDULE_DELAY_DEFAULT,
@@ -563,7 +563,7 @@ mod tests {
563563

564564
#[tokio::test]
565565
async fn test_batch_span_processor() {
566-
let (exporter, mut export_receiver, _shutdown_receiver) = new_tokio_test_exporter();
566+
let (exporter, mut export_receiver, _shutdown_receiver) = new_test_exporter();
567567
let config = BatchConfigBuilder::default()
568568
.with_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
569569
.build();

0 commit comments

Comments
 (0)