Skip to content

Commit 5401350

Browse files
authored
Merge branch 'main' into cijothomas/fix-int
2 parents a8356fa + c51c4b2 commit 5401350

File tree

5 files changed

+104
-38
lines changed

5 files changed

+104
-38
lines changed

opentelemetry-sdk/CHANGELOG.md

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
- *Breaking* Removed the following deprecated methods:
4545
- `Logger::provider()` : Previously deprecated in version 0.27.1
4646
- `Logger::instrumentation_scope()` : Previously deprecated in version 0.27.1.
47-
Migration Guidance:
47+
Migration Guidance:
4848
- These methods were intended for log appenders. Keep the clone of the provider handle, instead of depending on above methods.
4949

5050
- *Breaking* - `PeriodicReader` Updates
@@ -82,7 +82,7 @@
8282
If your application cannot spin up new threads or you prefer using async
8383
runtimes, enable the
8484
"experimental_metrics_periodicreader_with_async_runtime" feature flag and
85-
adjust code as below.
85+
adjust code as below.
8686

8787
- *Before:*
8888

@@ -98,7 +98,7 @@
9898

9999
*Requirements:*
100100
- Enable the feature flag:
101-
`experimental_metrics_periodicreader_with_async_runtime`.
101+
`experimental_metrics_periodicreader_with_async_runtime`.
102102
- Continue enabling one of the async runtime feature flags: `rt-tokio`,
103103
`rt-tokio-current-thread`, or `rt-async-std`.
104104

@@ -175,7 +175,7 @@ metadata, a feature introduced in version 0.1.40. [#2418](https://github.com/ope
175175

176176
*Requirements:*
177177
- Enable the feature flag:
178-
`experimental_logs_batch_log_processor_with_async_runtime`.
178+
`experimental_logs_batch_log_processor_with_async_runtime`.
179179
- Continue enabling one of the async runtime feature flags: `rt-tokio`,
180180
`rt-tokio-current-thread`, or `rt-async-std`.
181181

@@ -239,13 +239,23 @@ metadata, a feature introduced in version 0.1.40. [#2418](https://github.com/ope
239239

240240
*Requirements:*
241241
- Enable the feature flag:
242-
`experimental_trace_batch_span_processor_with_async_runtime`.
242+
`experimental_trace_batch_span_processor_with_async_runtime`.
243243
- Continue enabling one of the async runtime feature flags: `rt-tokio`,
244244
`rt-tokio-current-thread`, or `rt-async-std`.
245245

246246
- Bug fix: Empty Tracer names are retained as-is instead of replacing with
247247
"rust.opentelemetry.io/sdk/tracer"
248248
[#2486](https://github.com/open-telemetry/opentelemetry-rust/pull/2486)
249+
- Update `EnvResourceDetector` to allow resource attribute values containing
250+
equal signs (`"="`). [#2120](https://github.com/open-telemetry/opentelemetry-rust/pull/2120)
251+
252+
- **Breaking** Introduced `experimental_async_runtime` feature for runtime-specific traits.
253+
- Runtime-specific features (`rt-tokio`, `rt-tokio-current-thread`, and `rt-async-std`)
254+
now depend on the `experimental_async_runtime` feature.
255+
- For most users, no action is required. Enabling runtime features such as `rt-tokio`, `rt-tokio-current-thread`,
256+
or `rt-async-std` will automatically enable the `experimental_async_runtime` feature.
257+
- If you're implementing a custom runtime, you must explicitly enable the experimental_async_runtime` feature in your
258+
Cargo.toml and implement the required `Runtime` traits.
249259

250260
## 0.27.1
251261

@@ -274,10 +284,10 @@ Released 2024-Nov-27
274284
- Bug fix: Empty Logger names are retained as-is instead of replacing with
275285
"rust.opentelemetry.io/sdk/logger"
276286
[#2316](https://github.com/open-telemetry/opentelemetry-rust/pull/2316)
277-
287+
278288
- `Logger::provider`: This method is deprecated as of version `0.27.1`. To be removed in `0.28.0`.
279289
- `Logger::instrumentation_scope`: This method is deprecated as of version `0.27.1`. To be removed in `0.28.0`
280-
Migration Guidance:
290+
Migration Guidance:
281291
- These methods are intended for log appenders. Keep the clone of the provider handle, instead of depending on above methods.
282292

283293

@@ -303,7 +313,7 @@ Released 2024-Nov-11
303313
- **Replaced**
304314
- ([#2217](https://github.com/open-telemetry/opentelemetry-rust/pull/2217)): Removed `{Delta,Cumulative}TemporalitySelector::new()` in favor of directly using `Temporality` enum to simplify the configuration of MetricsExporterBuilder with different temporalities.
305315
- **Renamed**
306-
- ([#2232](https://github.com/open-telemetry/opentelemetry-rust/pull/2232)): The `init` method used to create instruments has been renamed to `build`.
316+
- ([#2232](https://github.com/open-telemetry/opentelemetry-rust/pull/2232)): The `init` method used to create instruments has been renamed to `build`.
307317
Before:
308318
```rust
309319
let counter = meter.u64_counter("my_counter").init();

opentelemetry-sdk/Cargo.toml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,10 @@ logs = ["opentelemetry/logs", "serde_json"]
4949
spec_unstable_logs_enabled = ["logs", "opentelemetry/spec_unstable_logs_enabled"]
5050
metrics = ["opentelemetry/metrics", "glob", "async-trait"]
5151
testing = ["opentelemetry/testing", "trace", "metrics", "logs", "rt-async-std", "rt-tokio", "rt-tokio-current-thread", "tokio/macros", "tokio/rt-multi-thread"]
52-
rt-tokio = ["tokio", "tokio-stream"]
53-
rt-tokio-current-thread = ["tokio", "tokio-stream"]
54-
rt-async-std = ["async-std"]
52+
experimental_async_runtime = []
53+
rt-tokio = ["tokio", "tokio-stream", "experimental_async_runtime"]
54+
rt-tokio-current-thread = ["tokio", "tokio-stream", "experimental_async_runtime"]
55+
rt-async-std = ["async-std", "experimental_async_runtime"]
5556
internal-logs = ["tracing"]
5657
experimental_metrics_periodicreader_with_async_runtime = ["metrics"]
5758
spec_unstable_metrics_views = ["metrics"]

opentelemetry-sdk/src/lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@
9494
//! Support for recording and exporting telemetry asynchronously and perform
9595
//! metrics aggregation can be added via the following flags:
9696
//!
97+
//! * `experimental_async_runtime`: Enables the experimental `Runtime` trait and related functionality.
9798
//! * `rt-tokio`: Spawn telemetry tasks using [tokio]'s multi-thread runtime.
9899
//! * `rt-tokio-current-thread`: Spawn telemetry tasks on a separate runtime so that the main runtime won't be blocked.
99100
//! * `rt-async-std`: Spawn telemetry tasks using [async-std]'s runtime.
@@ -133,6 +134,7 @@ pub mod metrics;
133134
#[cfg_attr(docsrs, doc(cfg(feature = "trace")))]
134135
pub mod propagation;
135136
pub mod resource;
137+
#[cfg(feature = "experimental_async_runtime")]
136138
pub mod runtime;
137139
#[cfg(any(feature = "testing", test))]
138140
#[cfg_attr(docsrs, doc(cfg(any(feature = "testing", test))))]

opentelemetry-sdk/src/resource/env.rs

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -45,12 +45,12 @@ impl Default for EnvResourceDetector {
4545
fn construct_otel_resources(s: String) -> Resource {
4646
Resource::builder_empty()
4747
.with_attributes(s.split_terminator(',').filter_map(|entry| {
48-
let mut parts = entry.splitn(2, '=');
49-
let key = parts.next()?.trim();
50-
let value = parts.next()?.trim();
51-
if value.find('=').is_some() {
52-
return None;
53-
}
48+
let parts = match entry.split_once('=') {
49+
Some(p) => p,
50+
None => return None,
51+
};
52+
let key = parts.0.trim();
53+
let value = parts.1.trim();
5454

5555
Some(KeyValue::new(key.to_owned(), value.to_owned()))
5656
}))
@@ -106,7 +106,7 @@ mod tests {
106106
[
107107
(
108108
"OTEL_RESOURCE_ATTRIBUTES",
109-
Some("key=value, k = v , a= x, a=z"),
109+
Some("key=value, k = v , a= x, a=z,base64=SGVsbG8sIFdvcmxkIQ=="),
110110
),
111111
("IRRELEVANT", Some("20200810")),
112112
],
@@ -121,6 +121,7 @@ mod tests {
121121
KeyValue::new("k", "v"),
122122
KeyValue::new("a", "x"),
123123
KeyValue::new("a", "z"),
124+
KeyValue::new("base64", "SGVsbG8sIFdvcmxkIQ=="), // base64('Hello, World!')
124125
])
125126
.build()
126127
);

opentelemetry-sdk/src/runtime.rs

Lines changed: 72 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ use thiserror::Error;
1515
///
1616
/// [Tokio]: https://crates.io/crates/tokio
1717
/// [async-std]: https://crates.io/crates/async-std
18+
#[cfg(feature = "experimental_async_runtime")]
1819
pub trait Runtime: Clone + Send + Sync + 'static {
1920
/// A future stream, which returns items in a previously specified interval. The item type is
2021
/// not important.
@@ -44,13 +45,19 @@ pub trait Runtime: Clone + Send + Sync + 'static {
4445
}
4546

4647
/// Runtime implementation, which works with Tokio's multi thread runtime.
47-
#[cfg(feature = "rt-tokio")]
48-
#[cfg_attr(docsrs, doc(cfg(feature = "rt-tokio")))]
48+
#[cfg(all(feature = "experimental_async_runtime", feature = "rt-tokio"))]
49+
#[cfg_attr(
50+
docsrs,
51+
doc(cfg(all(feature = "experimental_async_runtime", feature = "rt-tokio")))
52+
)]
4953
#[derive(Debug, Clone)]
5054
pub struct Tokio;
5155

52-
#[cfg(feature = "rt-tokio")]
53-
#[cfg_attr(docsrs, doc(cfg(feature = "rt-tokio")))]
56+
#[cfg(all(feature = "experimental_async_runtime", feature = "rt-tokio"))]
57+
#[cfg_attr(
58+
docsrs,
59+
doc(cfg(all(feature = "experimental_async_runtime", feature = "rt-tokio")))
60+
)]
5461
impl Runtime for Tokio {
5562
type Interval = tokio_stream::wrappers::IntervalStream;
5663
type Delay = ::std::pin::Pin<Box<tokio::time::Sleep>>;
@@ -71,13 +78,31 @@ impl Runtime for Tokio {
7178
}
7279

7380
/// Runtime implementation, which works with Tokio's current thread runtime.
74-
#[cfg(feature = "rt-tokio-current-thread")]
75-
#[cfg_attr(docsrs, doc(cfg(feature = "rt-tokio-current-thread")))]
81+
#[cfg(all(
82+
feature = "experimental_async_runtime",
83+
feature = "rt-tokio-current-thread"
84+
))]
85+
#[cfg_attr(
86+
docsrs,
87+
doc(cfg(all(
88+
feature = "experimental_async_runtime",
89+
feature = "rt-tokio-current-thread"
90+
)))
91+
)]
7692
#[derive(Debug, Clone)]
7793
pub struct TokioCurrentThread;
7894

79-
#[cfg(feature = "rt-tokio-current-thread")]
80-
#[cfg_attr(docsrs, doc(cfg(feature = "rt-tokio-current-thread")))]
95+
#[cfg(all(
96+
feature = "experimental_async_runtime",
97+
feature = "rt-tokio-current-thread"
98+
))]
99+
#[cfg_attr(
100+
docsrs,
101+
doc(cfg(all(
102+
feature = "experimental_async_runtime",
103+
feature = "rt-tokio-current-thread"
104+
)))
105+
)]
81106
impl Runtime for TokioCurrentThread {
82107
type Interval = tokio_stream::wrappers::IntervalStream;
83108
type Delay = ::std::pin::Pin<Box<tokio::time::Sleep>>;
@@ -108,13 +133,19 @@ impl Runtime for TokioCurrentThread {
108133
}
109134

110135
/// Runtime implementation, which works with async-std.
111-
#[cfg(feature = "rt-async-std")]
112-
#[cfg_attr(docsrs, doc(cfg(feature = "rt-async-std")))]
136+
#[cfg(all(feature = "experimental_async_runtime", feature = "rt-async-std"))]
137+
#[cfg_attr(
138+
docsrs,
139+
doc(cfg(all(feature = "experimental_async_runtime", feature = "rt-async-std")))
140+
)]
113141
#[derive(Debug, Clone)]
114142
pub struct AsyncStd;
115143

116-
#[cfg(feature = "rt-async-std")]
117-
#[cfg_attr(docsrs, doc(cfg(feature = "rt-async-std")))]
144+
#[cfg(all(feature = "experimental_async_runtime", feature = "rt-async-std"))]
145+
#[cfg_attr(
146+
docsrs,
147+
doc(cfg(all(feature = "experimental_async_runtime", feature = "rt-async-std")))
148+
)]
118149
impl Runtime for AsyncStd {
119150
type Interval = async_std::stream::Interval;
120151
type Delay = BoxFuture<'static, ()>;
@@ -138,6 +169,7 @@ impl Runtime for AsyncStd {
138169
///
139170
/// [log]: crate::logs::BatchLogProcessor
140171
/// [span]: crate::trace::BatchSpanProcessor
172+
#[cfg(feature = "experimental_async_runtime")]
141173
pub trait RuntimeChannel: Runtime {
142174
/// A future stream to receive batch messages from channels.
143175
type Receiver<T: Debug + Send>: Stream<Item = T> + Send;
@@ -152,6 +184,7 @@ pub trait RuntimeChannel: Runtime {
152184
}
153185

154186
/// Error returned by a [`TrySend`] implementation.
187+
#[cfg(feature = "experimental_async_runtime")]
155188
#[derive(Debug, Error)]
156189
pub enum TrySendError {
157190
/// Send failed due to the channel being full.
@@ -166,6 +199,7 @@ pub enum TrySendError {
166199
}
167200

168201
/// TrySend is an abstraction of `Sender` that is capable of sending messages through a reference.
202+
#[cfg(feature = "experimental_async_runtime")]
169203
pub trait TrySend: Sync + Send {
170204
/// The message that will be sent.
171205
type Message;
@@ -176,7 +210,10 @@ pub trait TrySend: Sync + Send {
176210
fn try_send(&self, item: Self::Message) -> Result<(), TrySendError>;
177211
}
178212

179-
#[cfg(any(feature = "rt-tokio", feature = "rt-tokio-current-thread"))]
213+
#[cfg(all(
214+
feature = "experimental_async_runtime",
215+
any(feature = "rt-tokio", feature = "rt-tokio-current-thread")
216+
))]
180217
impl<T: Send> TrySend for tokio::sync::mpsc::Sender<T> {
181218
type Message = T;
182219

@@ -188,8 +225,11 @@ impl<T: Send> TrySend for tokio::sync::mpsc::Sender<T> {
188225
}
189226
}
190227

191-
#[cfg(feature = "rt-tokio")]
192-
#[cfg_attr(docsrs, doc(cfg(feature = "rt-tokio")))]
228+
#[cfg(all(feature = "experimental_async_runtime", feature = "rt-tokio"))]
229+
#[cfg_attr(
230+
docsrs,
231+
doc(cfg(all(feature = "experimental_async_runtime", feature = "rt-tokio")))
232+
)]
193233
impl RuntimeChannel for Tokio {
194234
type Receiver<T: Debug + Send> = tokio_stream::wrappers::ReceiverStream<T>;
195235
type Sender<T: Debug + Send> = tokio::sync::mpsc::Sender<T>;
@@ -206,8 +246,17 @@ impl RuntimeChannel for Tokio {
206246
}
207247
}
208248

209-
#[cfg(feature = "rt-tokio-current-thread")]
210-
#[cfg_attr(docsrs, doc(cfg(feature = "rt-tokio-current-thread")))]
249+
#[cfg(all(
250+
feature = "experimental_async_runtime",
251+
feature = "rt-tokio-current-thread"
252+
))]
253+
#[cfg_attr(
254+
docsrs,
255+
doc(cfg(all(
256+
feature = "experimental_async_runtime",
257+
feature = "rt-tokio-current-thread"
258+
)))
259+
)]
211260
impl RuntimeChannel for TokioCurrentThread {
212261
type Receiver<T: Debug + Send> = tokio_stream::wrappers::ReceiverStream<T>;
213262
type Sender<T: Debug + Send> = tokio::sync::mpsc::Sender<T>;
@@ -224,7 +273,7 @@ impl RuntimeChannel for TokioCurrentThread {
224273
}
225274
}
226275

227-
#[cfg(feature = "rt-async-std")]
276+
#[cfg(all(feature = "experimental_async_runtime", feature = "rt-async-std"))]
228277
impl<T: Send> TrySend for async_std::channel::Sender<T> {
229278
type Message = T;
230279

@@ -236,8 +285,11 @@ impl<T: Send> TrySend for async_std::channel::Sender<T> {
236285
}
237286
}
238287

239-
#[cfg(feature = "rt-async-std")]
240-
#[cfg_attr(docsrs, doc(cfg(feature = "rt-async-std")))]
288+
#[cfg(all(feature = "experimental_async_runtime", feature = "rt-async-std"))]
289+
#[cfg_attr(
290+
docsrs,
291+
doc(cfg(all(feature = "experimental_async_runtime", feature = "rt-async-std")))
292+
)]
241293
impl RuntimeChannel for AsyncStd {
242294
type Receiver<T: Debug + Send> = async_std::channel::Receiver<T>;
243295
type Sender<T: Debug + Send> = async_std::channel::Sender<T>;

0 commit comments

Comments
 (0)