Skip to content

Commit c233050

Browse files
authored
Merge branch 'main' into otlp-exporter-env
2 parents fa1d5ed + e43f3df commit c233050

File tree

12 files changed

+29
-117
lines changed

12 files changed

+29
-117
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>`

docs/design/logs.md

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,13 @@ They get called in the order of registration. Log records are passed to the
195195
records, enrich them, filter them, and export to destinations by leveraging
196196
LogRecord Exporters.
197197

198+
Similar to [LoggerProvider](#sdkloggerprovider), methods on the `LogProcessor`
199+
trait also takes a immutable self (`&self`) only, forcing the need to use
200+
interior mutability, if any mutation is required. The exception to this is
201+
`set_resource`, which takes a `&mut self`. This is acceptable as `set_resource`
202+
is called by the `SdkLoggerProvider` during build() method only, and is not
203+
required after that.
204+
198205
Following built-in Log processors are provided in the Log SDK:
199206

200207
##### SimpleLogProcessor
@@ -232,8 +239,13 @@ other words, that many logs can be lost if the app crashes in the middle.
232239

233240
## LogExporters
234241

235-
LogExporters are responsible for exporting logs to a destination. Some of them
236-
include:
242+
LogExporters are responsible for exporting logs to a destination.
243+
`SdkLoggerProvider` does not have a direct knowledge of the `LogExporter`, as it
244+
only deals with `LogProcessors`. It is the `LogProcessor`s that invokes
245+
`LogExporter` methods. Most methods on `LogExporter` trait also only takes
246+
`&self`, following the same reasoning as [LogProcessors](#logrecord-processors)
247+
248+
Some of the exporters are:
237249

238250
1. **InMemoryExporter** - exports to an in-memory list, primarily for
239251
unit-testing. This is used extensively in the repo itself, and external users

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/benches/log_enabled.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,12 @@
55
Total Number of Cores:   14 (10 performance and 4 efficiency)
66
| Test | Average time|
77
|---------------------------------------------|-------------|
8-
| exporter_disabled_concurrent_processor | 1.9 ns |
9-
| exporter_disabled_simple_processor | 5.0 ns |
8+
| exporter_disabled_concurrent_processor | 1.0 ns |
9+
| exporter_disabled_simple_processor | 4.5 ns |
1010
*/
1111

12+
// cargo bench --bench log_enabled --features="spec_unstable_logs_enabled,experimental_logs_concurrent_log_processor"
13+
1214
use criterion::{criterion_group, criterion_main, Criterion};
1315
use opentelemetry::logs::{Logger, LoggerProvider};
1416
use opentelemetry_sdk::error::OTelSdkResult;

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/logs/logger.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ impl opentelemetry::logs::Logger for SdkLogger {
5050
}
5151

5252
#[cfg(feature = "spec_unstable_logs_enabled")]
53+
#[inline]
5354
fn event_enabled(&self, level: Severity, target: &str, name: Option<&str>) -> bool {
5455
self.provider
5556
.log_processors()

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
}

0 commit comments

Comments
 (0)