Skip to content

chore: remove deprecated functions/methods in trace::Config #2810

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Mar 16, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 6 additions & 9 deletions opentelemetry-otlp/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -153,15 +153,12 @@
//!
//! let tracer_provider = opentelemetry_sdk::trace::SdkTracerProvider::builder()
//! .with_batch_exporter(exporter)
//! .with_config(
//! trace::Config::default()
//! .with_sampler(Sampler::AlwaysOn)
//! .with_id_generator(RandomIdGenerator::default())
//! .with_max_events_per_span(64)
//! .with_max_attributes_per_span(16)
//! .with_max_events_per_span(16)
//! .with_resource(Resource::builder_empty().with_attributes([KeyValue::new("service.name", "example")]).build()),
//! ).build();
//! .with_sampler(Sampler::AlwaysOn)
//! .with_id_generator(RandomIdGenerator::default())
//! .with_max_events_per_span(64)
//! .with_max_attributes_per_span(16)
//! .with_resource(Resource::builder_empty().with_attributes([KeyValue::new("service.name", "example")]).build())
//! .build();
//! global::set_tracer_provider(tracer_provider.clone());
//! let tracer = global::tracer("tracer-name");
//! # tracer
Expand Down
1 change: 1 addition & 0 deletions opentelemetry-sdk/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@
- **Breaking** for custom `LogProcessor` authors: Changed `set_resource`
to require mutable ref.
`fn set_resource(&mut self, _resource: &Resource) {}`
- **Breaking** Removed deprecated functions and methods related to `trace::Config`

## 0.28.0

Expand Down
1 change: 0 additions & 1 deletion opentelemetry-sdk/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,6 @@ pub mod runtime;
#[cfg_attr(docsrs, doc(cfg(any(feature = "testing", test))))]
pub mod testing;

#[allow(deprecated)]
#[cfg(feature = "trace")]
#[cfg_attr(docsrs, doc(cfg(feature = "trace")))]
pub mod trace;
Expand Down
98 changes: 0 additions & 98 deletions opentelemetry-sdk/src/trace/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,6 @@ use std::borrow::Cow;
use std::env;
use std::str::FromStr;

/// Default trace configuration
#[deprecated(since = "0.23.0", note = "Use Config::default() instead")]
pub fn config() -> Config {
Config::default()
}

/// Tracer configuration
#[derive(Debug)]
#[non_exhaustive]
Expand All @@ -32,98 +26,6 @@ pub struct Config {
pub resource: Cow<'static, Resource>,
}

impl Config {
/// Specify the sampler to be used.
#[deprecated(
since = "0.27.1",
note = "Config is becoming private. Please use Builder::with_sampler(...) instead."
)]
pub fn with_sampler<T: crate::trace::ShouldSample + 'static>(mut self, sampler: T) -> Self {
self.sampler = Box::new(sampler);
self
}

/// Specify the id generator to be used.
#[deprecated(
since = "0.27.1",
note = "Config is becoming private. Please use Builder::with_id_generator(...) instead."
)]
pub fn with_id_generator<T: IdGenerator + 'static>(mut self, id_generator: T) -> Self {
self.id_generator = Box::new(id_generator);
self
}

/// Specify the maximum number of events that can be recorded per span.
#[deprecated(
since = "0.27.1",
note = "Config is becoming private. Please use Builder::with_max_events_per_span(...) instead."
)]
pub fn with_max_events_per_span(mut self, max_events: u32) -> Self {
self.span_limits.max_events_per_span = max_events;
self
}

/// Specify the maximum number of attributes that can be recorded per span.
#[deprecated(
since = "0.27.1",
note = "Config is becoming private. Please use Builder::with_max_attributes_per_span(...) instead."
)]
pub fn with_max_attributes_per_span(mut self, max_attributes: u32) -> Self {
self.span_limits.max_attributes_per_span = max_attributes;
self
}

/// Specify the maximum number of links that can be recorded per span.
#[deprecated(
since = "0.27.1",
note = "Config is becoming private. Please use Builder::with_max_links_per_span(...) instead."
)]
pub fn with_max_links_per_span(mut self, max_links: u32) -> Self {
self.span_limits.max_links_per_span = max_links;
self
}

/// Specify the maximum number of attributes one event can have.
#[deprecated(
since = "0.27.1",
note = "Config is becoming private. Please use Builder::with_max_attributes_per_event(...) instead."
)]
pub fn with_max_attributes_per_event(mut self, max_attributes: u32) -> Self {
self.span_limits.max_attributes_per_event = max_attributes;
self
}

/// Specify the maximum number of attributes one link can have.
#[deprecated(
since = "0.27.1",
note = "Config is becoming private. Please use Builder::with_max_attributes_per_link(...) instead."
)]
pub fn with_max_attributes_per_link(mut self, max_attributes: u32) -> Self {
self.span_limits.max_attributes_per_link = max_attributes;
self
}

/// Specify all limit via the span_limits
#[deprecated(
since = "0.27.1",
note = "Config is becoming private. Please use Builder::with_span_limits(...) instead."
)]
pub fn with_span_limits(mut self, span_limits: SpanLimits) -> Self {
self.span_limits = span_limits;
self
}

/// Specify the attributes representing the entity that produces telemetry
#[deprecated(
since = "0.27.1",
note = "Config is becoming private. Please use Builder::with_resource(...) instead."
)]
pub fn with_resource(mut self, resource: Resource) -> Self {
self.resource = Cow::Owned(resource);
self
}
}

impl Default for Config {
/// Create default global sdk configuration.
fn default() -> Self {
Expand Down
2 changes: 1 addition & 1 deletion opentelemetry-sdk/src/trace/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ mod span_processor;
pub mod span_processor_with_async_runtime;
mod tracer;

pub use config::{config, Config};
pub use config::Config;
pub use error::{TraceError, TraceResult};
pub use events::SpanEvents;
pub use export::{SpanData, SpanExporter};
Expand Down
11 changes: 1 addition & 10 deletions opentelemetry-sdk/src/trace/provider.rs
Original file line number Diff line number Diff line change
Expand Up @@ -345,15 +345,6 @@ impl TracerProviderBuilder {
TracerProviderBuilder { processors, ..self }
}

/// The sdk [`crate::trace::Config`] that this provider will use.
#[deprecated(
since = "0.27.1",
note = "Config is becoming a private type. Use Builder::with_{config_name}(resource) instead. ex: Builder::with_resource(resource)"
)]
pub fn with_config(self, config: crate::trace::Config) -> Self {
TracerProviderBuilder { config, ..self }
}

/// Specify the sampler to be used.
pub fn with_sampler<T: crate::trace::ShouldSample + 'static>(mut self, sampler: T) -> Self {
self.config.sampler = Box::new(sampler);
Expand Down Expand Up @@ -428,7 +419,7 @@ impl TracerProviderBuilder {

// Now, we can update the config with the resource.
if let Some(resource) = self.resource {
config = config.with_resource(resource);
config.resource = Cow::Owned(resource);
};

// Standard config will contain an owned [`Resource`] (either sdk default or use supplied)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@
.unwrap();

let resp = client
.send(request)
.send_bytes(request)

Check warning on line 237 in opentelemetry-sdk/src/trace/sampler/jaeger_remote/sampler.rs

View check run for this annotation

Codecov / codecov/patch

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

Added line #L237 was not covered by tests
.await
.map_err(|err| format!("the request is failed to send {}", err))?;

Expand Down
2 changes: 1 addition & 1 deletion opentelemetry-semantic-conventions/src/resource.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
//!
//! ```rust
//! use opentelemetry::KeyValue;
//! use opentelemetry_sdk::{trace::{config, SdkTracerProvider}, Resource};
//! use opentelemetry_sdk::{trace::SdkTracerProvider, Resource};
//! use opentelemetry_semantic_conventions as semconv;
//!
//! let _tracer = SdkTracerProvider::builder()
Expand Down