diff --git a/opentelemetry-sdk/CHANGELOG.md b/opentelemetry-sdk/CHANGELOG.md index 3f0df7bccc..496cc3543f 100644 --- a/opentelemetry-sdk/CHANGELOG.md +++ b/opentelemetry-sdk/CHANGELOG.md @@ -23,6 +23,8 @@ - Fixed a bug related to cumulative aggregation of `Gauge` measurements. [#1975](https://github.com/open-telemetry/opentelemetry-rust/issues/1975). [#2021](https://github.com/open-telemetry/opentelemetry-rust/pull/2021) +- Provide default implementation for `event_enabled` method in `LogProcessor` + trait that returns `true` always. ## v0.24.1 diff --git a/opentelemetry-sdk/benches/log.rs b/opentelemetry-sdk/benches/log.rs index 198be8cf2f..71d5fc699f 100644 --- a/opentelemetry-sdk/benches/log.rs +++ b/opentelemetry-sdk/benches/log.rs @@ -45,16 +45,6 @@ impl LogProcessor for NoopProcessor { fn shutdown(&self) -> LogResult<()> { Ok(()) } - - #[cfg(feature = "logs_level_enabled")] - fn event_enabled( - &self, - _level: opentelemetry::logs::Severity, - _target: &str, - _name: &str, - ) -> bool { - true - } } fn log_benchmark_group(c: &mut Criterion, name: &str, f: F) { diff --git a/opentelemetry-sdk/src/export/logs/mod.rs b/opentelemetry-sdk/src/export/logs/mod.rs index 9588339462..e1426553a1 100644 --- a/opentelemetry-sdk/src/export/logs/mod.rs +++ b/opentelemetry-sdk/src/export/logs/mod.rs @@ -21,6 +21,7 @@ pub trait LogExporter: Send + Sync + Debug { #[cfg(feature = "logs_level_enabled")] /// Chek if logs are enabled. fn event_enabled(&self, _level: Severity, _target: &str, _name: &str) -> bool { + // By default, all logs are enabled true } /// Set the resource for the exporter. diff --git a/opentelemetry-sdk/src/logs/log_emitter.rs b/opentelemetry-sdk/src/logs/log_emitter.rs index faadf473b3..c9d3e5a828 100644 --- a/opentelemetry-sdk/src/logs/log_emitter.rs +++ b/opentelemetry-sdk/src/logs/log_emitter.rs @@ -359,11 +359,6 @@ mod tests { .expect("lock poisoned"); Ok(()) } - - #[cfg(feature = "logs_level_enabled")] - fn event_enabled(&self, _level: Severity, _target: &str, _name: &str) -> bool { - true - } } #[test] fn test_logger_provider_default_resource() { @@ -584,10 +579,5 @@ mod tests { *self.shutdown_called.lock().unwrap() = true; Ok(()) } - - #[cfg(feature = "logs_level_enabled")] - fn event_enabled(&self, _level: Severity, _target: &str, _name: &str) -> bool { - true - } } } diff --git a/opentelemetry-sdk/src/logs/log_processor.rs b/opentelemetry-sdk/src/logs/log_processor.rs index 57bb8afe71..7366f19791 100644 --- a/opentelemetry-sdk/src/logs/log_processor.rs +++ b/opentelemetry-sdk/src/logs/log_processor.rs @@ -64,7 +64,10 @@ pub trait LogProcessor: Send + Sync + Debug { fn shutdown(&self) -> LogResult<()>; #[cfg(feature = "logs_level_enabled")] /// Check if logging is enabled - fn event_enabled(&self, level: Severity, target: &str, name: &str) -> bool; + fn event_enabled(&self, _level: Severity, _target: &str, _name: &str) -> bool { + // By default, all logs are enabled + true + } /// Set the resource for the log processor. fn set_resource(&self, _resource: &Resource) {} @@ -130,11 +133,6 @@ impl LogProcessor for SimpleLogProcessor { exporter.set_resource(resource); } } - - #[cfg(feature = "logs_level_enabled")] - fn event_enabled(&self, _level: Severity, _target: &str, _name: &str) -> bool { - true - } } /// A [`LogProcessor`] that asynchronously buffers log records and reports @@ -162,11 +160,6 @@ impl LogProcessor for BatchLogProcessor { } } - #[cfg(feature = "logs_level_enabled")] - fn event_enabled(&self, _level: Severity, _target: &str, _name: &str) -> bool { - true - } - fn force_flush(&self) -> LogResult<()> { let (res_sender, res_receiver) = oneshot::channel(); self.message_sender @@ -529,8 +522,6 @@ mod tests { }; use async_trait::async_trait; use opentelemetry::logs::AnyValue; - #[cfg(feature = "logs_level_enabled")] - use opentelemetry::logs::Severity; use opentelemetry::logs::{Logger, LoggerProvider as _}; use opentelemetry::Key; use opentelemetry::{logs::LogResult, KeyValue}; @@ -830,11 +821,6 @@ mod tests { self.logs.lock().unwrap().push(data.clone()); //clone as the LogProcessor is storing the data. } - #[cfg(feature = "logs_level_enabled")] - fn event_enabled(&self, _level: Severity, _target: &str, _name: &str) -> bool { - true - } - fn force_flush(&self) -> LogResult<()> { Ok(()) } @@ -864,11 +850,6 @@ mod tests { self.logs.lock().unwrap().push(data.clone()); } - #[cfg(feature = "logs_level_enabled")] - fn event_enabled(&self, _level: Severity, _target: &str, _name: &str) -> bool { - true - } - fn force_flush(&self) -> LogResult<()> { Ok(()) } diff --git a/stress/src/logs.rs b/stress/src/logs.rs index d091dccc6b..6cec97463c 100644 --- a/stress/src/logs.rs +++ b/stress/src/logs.rs @@ -29,15 +29,6 @@ impl LogProcessor for NoOpLogProcessor { fn shutdown(&self) -> opentelemetry::logs::LogResult<()> { Ok(()) } - - fn event_enabled( - &self, - _level: opentelemetry::logs::Severity, - _target: &str, - _name: &str, - ) -> bool { - true - } } fn main() {