Skip to content

Commit 6d4c136

Browse files
authored
Merge branch 'main' into cijothomas/jaeger
2 parents 1dcc869 + 1bce83f commit 6d4c136

File tree

14 files changed

+201
-241
lines changed

14 files changed

+201
-241
lines changed

opentelemetry-otlp/src/lib.rs

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -207,15 +207,12 @@
207207
//!
208208
//! let tracer_provider = opentelemetry_sdk::trace::SdkTracerProvider::builder()
209209
//! .with_batch_exporter(exporter)
210-
//! .with_config(
211-
//! trace::Config::default()
212-
//! .with_sampler(Sampler::AlwaysOn)
213-
//! .with_id_generator(RandomIdGenerator::default())
214-
//! .with_max_events_per_span(64)
215-
//! .with_max_attributes_per_span(16)
216-
//! .with_max_events_per_span(16)
217-
//! .with_resource(Resource::builder_empty().with_attributes([KeyValue::new("service.name", "example")]).build()),
218-
//! ).build();
210+
//! .with_sampler(Sampler::AlwaysOn)
211+
//! .with_id_generator(RandomIdGenerator::default())
212+
//! .with_max_events_per_span(64)
213+
//! .with_max_attributes_per_span(16)
214+
//! .with_resource(Resource::builder_empty().with_attributes([KeyValue::new("service.name", "example")]).build())
215+
//! .build();
219216
//! global::set_tracer_provider(tracer_provider.clone());
220217
//! let tracer = global::tracer("tracer-name");
221218
//! # tracer

opentelemetry-sdk/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@
7474
- **Breaking** for custom `LogProcessor` authors: Changed `set_resource`
7575
to require mutable ref.
7676
`fn set_resource(&mut self, _resource: &Resource) {}`
77+
- **Breaking** Removed deprecated functions and methods related to `trace::Config`
7778

7879
## 0.28.0
7980

opentelemetry-sdk/src/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,6 @@ pub mod runtime;
136136
#[cfg_attr(docsrs, doc(cfg(any(feature = "testing", test))))]
137137
pub mod testing;
138138

139-
#[allow(deprecated)]
140139
#[cfg(feature = "trace")]
141140
#[cfg_attr(docsrs, doc(cfg(feature = "trace")))]
142141
pub mod trace;

opentelemetry-sdk/src/trace/config.rs

Lines changed: 0 additions & 98 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,6 @@ use std::borrow::Cow;
99
use std::env;
1010
use std::str::FromStr;
1111

12-
/// Default trace configuration
13-
#[deprecated(since = "0.23.0", note = "Use Config::default() instead")]
14-
pub fn config() -> Config {
15-
Config::default()
16-
}
17-
1812
/// Tracer configuration
1913
#[derive(Debug)]
2014
#[non_exhaustive]
@@ -32,98 +26,6 @@ pub struct Config {
3226
pub resource: Cow<'static, Resource>,
3327
}
3428

35-
impl Config {
36-
/// Specify the sampler to be used.
37-
#[deprecated(
38-
since = "0.27.1",
39-
note = "Config is becoming private. Please use Builder::with_sampler(...) instead."
40-
)]
41-
pub fn with_sampler<T: crate::trace::ShouldSample + 'static>(mut self, sampler: T) -> Self {
42-
self.sampler = Box::new(sampler);
43-
self
44-
}
45-
46-
/// Specify the id generator to be used.
47-
#[deprecated(
48-
since = "0.27.1",
49-
note = "Config is becoming private. Please use Builder::with_id_generator(...) instead."
50-
)]
51-
pub fn with_id_generator<T: IdGenerator + 'static>(mut self, id_generator: T) -> Self {
52-
self.id_generator = Box::new(id_generator);
53-
self
54-
}
55-
56-
/// Specify the maximum number of events that can be recorded per span.
57-
#[deprecated(
58-
since = "0.27.1",
59-
note = "Config is becoming private. Please use Builder::with_max_events_per_span(...) instead."
60-
)]
61-
pub fn with_max_events_per_span(mut self, max_events: u32) -> Self {
62-
self.span_limits.max_events_per_span = max_events;
63-
self
64-
}
65-
66-
/// Specify the maximum number of attributes that can be recorded per span.
67-
#[deprecated(
68-
since = "0.27.1",
69-
note = "Config is becoming private. Please use Builder::with_max_attributes_per_span(...) instead."
70-
)]
71-
pub fn with_max_attributes_per_span(mut self, max_attributes: u32) -> Self {
72-
self.span_limits.max_attributes_per_span = max_attributes;
73-
self
74-
}
75-
76-
/// Specify the maximum number of links that can be recorded per span.
77-
#[deprecated(
78-
since = "0.27.1",
79-
note = "Config is becoming private. Please use Builder::with_max_links_per_span(...) instead."
80-
)]
81-
pub fn with_max_links_per_span(mut self, max_links: u32) -> Self {
82-
self.span_limits.max_links_per_span = max_links;
83-
self
84-
}
85-
86-
/// Specify the maximum number of attributes one event can have.
87-
#[deprecated(
88-
since = "0.27.1",
89-
note = "Config is becoming private. Please use Builder::with_max_attributes_per_event(...) instead."
90-
)]
91-
pub fn with_max_attributes_per_event(mut self, max_attributes: u32) -> Self {
92-
self.span_limits.max_attributes_per_event = max_attributes;
93-
self
94-
}
95-
96-
/// Specify the maximum number of attributes one link can have.
97-
#[deprecated(
98-
since = "0.27.1",
99-
note = "Config is becoming private. Please use Builder::with_max_attributes_per_link(...) instead."
100-
)]
101-
pub fn with_max_attributes_per_link(mut self, max_attributes: u32) -> Self {
102-
self.span_limits.max_attributes_per_link = max_attributes;
103-
self
104-
}
105-
106-
/// Specify all limit via the span_limits
107-
#[deprecated(
108-
since = "0.27.1",
109-
note = "Config is becoming private. Please use Builder::with_span_limits(...) instead."
110-
)]
111-
pub fn with_span_limits(mut self, span_limits: SpanLimits) -> Self {
112-
self.span_limits = span_limits;
113-
self
114-
}
115-
116-
/// Specify the attributes representing the entity that produces telemetry
117-
#[deprecated(
118-
since = "0.27.1",
119-
note = "Config is becoming private. Please use Builder::with_resource(...) instead."
120-
)]
121-
pub fn with_resource(mut self, resource: Resource) -> Self {
122-
self.resource = Cow::Owned(resource);
123-
self
124-
}
125-
}
126-
12729
impl Default for Config {
12830
/// Create default global sdk configuration.
12931
fn default() -> Self {

opentelemetry-sdk/src/trace/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ mod span_processor;
2222
pub mod span_processor_with_async_runtime;
2323
mod tracer;
2424

25-
pub use config::{config, Config};
25+
pub use config::Config;
2626
pub use error::{TraceError, TraceResult};
2727
pub use events::SpanEvents;
2828
pub use export::{SpanData, SpanExporter};

opentelemetry-sdk/src/trace/provider.rs

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -345,15 +345,6 @@ impl TracerProviderBuilder {
345345
TracerProviderBuilder { processors, ..self }
346346
}
347347

348-
/// The sdk [`crate::trace::Config`] that this provider will use.
349-
#[deprecated(
350-
since = "0.27.1",
351-
note = "Config is becoming a private type. Use Builder::with_{config_name}(resource) instead. ex: Builder::with_resource(resource)"
352-
)]
353-
pub fn with_config(self, config: crate::trace::Config) -> Self {
354-
TracerProviderBuilder { config, ..self }
355-
}
356-
357348
/// Specify the sampler to be used.
358349
pub fn with_sampler<T: crate::trace::ShouldSample + 'static>(mut self, sampler: T) -> Self {
359350
self.config.sampler = Box::new(sampler);
@@ -428,7 +419,7 @@ impl TracerProviderBuilder {
428419

429420
// Now, we can update the config with the resource.
430421
if let Some(resource) = self.resource {
431-
config = config.with_resource(resource);
422+
config.resource = Cow::Owned(resource);
432423
};
433424

434425
// Standard config will contain an owned [`Resource`] (either sdk default or use supplied)

opentelemetry-sdk/src/trace/sampler/jaeger_remote/sampler.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ impl JaegerRemoteSampler {
234234
.unwrap();
235235

236236
let resp = client
237-
.send(request)
237+
.send_bytes(request)
238238
.await
239239
.map_err(|err| format!("the request is failed to send {}", err))?;
240240

opentelemetry-sdk/src/trace/span_processor.rs

Lines changed: 58 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -704,6 +704,8 @@ impl Default for BatchConfigBuilder {
704704
/// * `OTEL_BSP_MAX_EXPORT_BATCH_SIZE`
705705
/// * `OTEL_BSP_EXPORT_TIMEOUT`
706706
/// * `OTEL_BSP_MAX_CONCURRENT_EXPORTS`
707+
///
708+
/// Note: Programmatic configuration overrides any value set via the environment variable.
707709
fn default() -> Self {
708710
BatchConfigBuilder {
709711
max_queue_size: OTEL_BSP_MAX_QUEUE_SIZE_DEFAULT,
@@ -720,7 +722,11 @@ impl BatchConfigBuilder {
720722
/// Set max_queue_size for [`BatchConfigBuilder`].
721723
/// It's the maximum queue size to buffer spans for delayed processing.
722724
/// If the queue gets full it will drops the spans.
723-
/// The default value of is 2048.
725+
/// The default value is 2048.
726+
///
727+
/// Corresponding environment variable: `OTEL_BSP_MAX_QUEUE_SIZE`.
728+
///
729+
/// Note: Programmatically setting this will override any value set via the environment variable.
724730
pub fn with_max_queue_size(mut self, max_queue_size: usize) -> Self {
725731
self.max_queue_size = max_queue_size;
726732
self
@@ -731,6 +737,10 @@ impl BatchConfigBuilder {
731737
/// more than one batch worth of spans then it processes multiple batches
732738
/// of spans one batch after the other without any delay. The default value
733739
/// is 512.
740+
///
741+
/// Corresponding environment variable: `OTEL_BSP_MAX_EXPORT_BATCH_SIZE`.
742+
///
743+
/// Note: Programmatically setting this will override any value set via the environment variable.
734744
pub fn with_max_export_batch_size(mut self, max_export_batch_size: usize) -> Self {
735745
self.max_export_batch_size = max_export_batch_size;
736746
self
@@ -743,6 +753,11 @@ impl BatchConfigBuilder {
743753
/// The default value is 1.
744754
/// If the max_concurrent_exports value is default value, it will cause exports to be performed
745755
/// synchronously on the BatchSpanProcessor task.
756+
/// The default value is 1.
757+
///
758+
/// Corresponding environment variable: `OTEL_BSP_MAX_CONCURRENT_EXPORTS`.
759+
///
760+
/// Note: Programmatically setting this will override any value set via the environment variable.
746761
pub fn with_max_concurrent_exports(mut self, max_concurrent_exports: usize) -> Self {
747762
self.max_concurrent_exports = max_concurrent_exports;
748763
self
@@ -751,6 +766,10 @@ impl BatchConfigBuilder {
751766
/// Set scheduled_delay_duration for [`BatchConfigBuilder`].
752767
/// It's the delay interval in milliseconds between two consecutive processing of batches.
753768
/// The default value is 5000 milliseconds.
769+
///
770+
/// Corresponding environment variable: `OTEL_BSP_SCHEDULE_DELAY`.
771+
///
772+
/// Note: Programmatically setting this will override any value set via the environment variable.
754773
pub fn with_scheduled_delay(mut self, scheduled_delay: Duration) -> Self {
755774
self.scheduled_delay = scheduled_delay;
756775
self
@@ -759,6 +778,10 @@ impl BatchConfigBuilder {
759778
/// Set max_export_timeout for [`BatchConfigBuilder`].
760779
/// It's the maximum duration to export a batch of data.
761780
/// The The default value is 30000 milliseconds.
781+
///
782+
/// Corresponding environment variable: `OTEL_BSP_EXPORT_TIMEOUT`.
783+
///
784+
/// Note: Programmatically setting this will override any value set via the environment variable.
762785
#[cfg(feature = "experimental_trace_batch_span_processor_with_async_runtime")]
763786
pub fn with_max_export_timeout(mut self, max_export_timeout: Duration) -> Self {
764787
self.max_export_timeout = max_export_timeout;
@@ -932,6 +955,40 @@ mod tests {
932955
);
933956
}
934957

958+
#[test]
959+
fn test_code_based_config_overrides_env_vars() {
960+
let env_vars = vec![
961+
(OTEL_BSP_EXPORT_TIMEOUT, Some("60000")),
962+
(OTEL_BSP_MAX_CONCURRENT_EXPORTS, Some("5")),
963+
(OTEL_BSP_MAX_EXPORT_BATCH_SIZE, Some("1024")),
964+
(OTEL_BSP_MAX_QUEUE_SIZE, Some("4096")),
965+
(OTEL_BSP_SCHEDULE_DELAY, Some("2000")),
966+
];
967+
968+
temp_env::with_vars(env_vars, || {
969+
let config = BatchConfigBuilder::default()
970+
.with_max_export_batch_size(512)
971+
.with_max_queue_size(2048)
972+
.with_scheduled_delay(Duration::from_millis(1000));
973+
#[cfg(feature = "experimental_trace_batch_span_processor_with_async_runtime")]
974+
let config = {
975+
config
976+
.with_max_concurrent_exports(10)
977+
.with_max_export_timeout(Duration::from_millis(2000))
978+
};
979+
let config = config.build();
980+
981+
assert_eq!(config.max_export_batch_size, 512);
982+
assert_eq!(config.max_queue_size, 2048);
983+
assert_eq!(config.scheduled_delay, Duration::from_millis(1000));
984+
#[cfg(feature = "experimental_trace_batch_span_processor_with_async_runtime")]
985+
{
986+
assert_eq!(config.max_concurrent_exports, 10);
987+
assert_eq!(config.max_export_timeout, Duration::from_millis(2000));
988+
}
989+
});
990+
}
991+
935992
#[test]
936993
fn test_batch_config_configurable_by_env_vars() {
937994
let env_vars = vec![

opentelemetry-semantic-conventions/src/resource.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
//!
1616
//! ```rust
1717
//! use opentelemetry::KeyValue;
18-
//! use opentelemetry_sdk::{trace::{config, SdkTracerProvider}, Resource};
18+
//! use opentelemetry_sdk::{trace::SdkTracerProvider, Resource};
1919
//! use opentelemetry_semantic_conventions as semconv;
2020
//!
2121
//! let _tracer = SdkTracerProvider::builder()

opentelemetry/src/context.rs

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,14 @@
1+
//! Execution-scoped context propagation.
2+
//!
3+
//! The `context` module provides mechanisms for propagating values across API boundaries and between
4+
//! logically associated execution units. It enables cross-cutting concerns to access their data in-process
5+
//! using a shared context object.
6+
//!
7+
//! # Main Types
8+
//!
9+
//! - [`Context`]: An immutable, execution-scoped collection of values.
10+
//!
11+
112
use crate::otel_warn;
213
#[cfg(feature = "trace")]
314
use crate::trace::context::SynchronizedSpan;
@@ -9,6 +20,10 @@ use std::hash::{BuildHasherDefault, Hasher};
920
use std::marker::PhantomData;
1021
use std::sync::Arc;
1122

23+
mod future_ext;
24+
25+
pub use future_ext::FutureExt;
26+
1227
thread_local! {
1328
static CURRENT_CONTEXT: RefCell<ContextStack> = RefCell::new(ContextStack::default());
1429
}
@@ -78,7 +93,7 @@ thread_local! {
7893
#[derive(Clone, Default)]
7994
pub struct Context {
8095
#[cfg(feature = "trace")]
81-
pub(super) span: Option<Arc<SynchronizedSpan>>,
96+
pub(crate) span: Option<Arc<SynchronizedSpan>>,
8297
entries: Option<Arc<EntryMap>>,
8398
}
8499

@@ -314,15 +329,15 @@ impl Context {
314329
}
315330

316331
#[cfg(feature = "trace")]
317-
pub(super) fn current_with_synchronized_span(value: SynchronizedSpan) -> Self {
332+
pub(crate) fn current_with_synchronized_span(value: SynchronizedSpan) -> Self {
318333
Context {
319334
span: Some(Arc::new(value)),
320335
entries: Context::map_current(|cx| cx.entries.clone()),
321336
}
322337
}
323338

324339
#[cfg(feature = "trace")]
325-
pub(super) fn with_synchronized_span(&self, value: SynchronizedSpan) -> Self {
340+
pub(crate) fn with_synchronized_span(&self, value: SynchronizedSpan) -> Self {
326341
Context {
327342
span: Some(Arc::new(value)),
328343
entries: self.entries.clone(),

0 commit comments

Comments
 (0)