From 0aa4f2dcd5cdf7b9b1daab6cc1c4964d35c62dcb Mon Sep 17 00:00:00 2001 From: Cijo Thomas Date: Tue, 13 Aug 2024 19:57:28 -0700 Subject: [PATCH 1/3] Provide default implementation for event_enabled trait in LogProcessor --- opentelemetry-sdk/CHANGELOG.md | 2 ++ opentelemetry-sdk/benches/log.rs | 10 --------- opentelemetry-sdk/src/export/logs/mod.rs | 1 + opentelemetry-sdk/src/logs/log_emitter.rs | 10 --------- opentelemetry-sdk/src/logs/log_processor.rs | 25 ++++----------------- stress/src/logs.rs | 9 -------- 6 files changed, 7 insertions(+), 50 deletions(-) diff --git a/opentelemetry-sdk/CHANGELOG.md b/opentelemetry-sdk/CHANGELOG.md index 3f0df7bccc..4d24eea062 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` trait in LogProcessor 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..3ca8f647af 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 @@ -830,11 +823,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 +852,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() { From 65ee2b14313639d8694041788dda8cd046a08c07 Mon Sep 17 00:00:00 2001 From: Cijo Thomas Date: Tue, 13 Aug 2024 20:00:09 -0700 Subject: [PATCH 2/3] fmt --- opentelemetry-sdk/CHANGELOG.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/opentelemetry-sdk/CHANGELOG.md b/opentelemetry-sdk/CHANGELOG.md index 4d24eea062..496cc3543f 100644 --- a/opentelemetry-sdk/CHANGELOG.md +++ b/opentelemetry-sdk/CHANGELOG.md @@ -23,8 +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` trait in LogProcessor that - returns `true` always. +- Provide default implementation for `event_enabled` method in `LogProcessor` + trait that returns `true` always. ## v0.24.1 From f31a1222038a7fa9ed7782d4f6ed7084e9b03847 Mon Sep 17 00:00:00 2001 From: Cijo Thomas Date: Tue, 13 Aug 2024 20:07:52 -0700 Subject: [PATCH 3/3] remove unused --- opentelemetry-sdk/src/logs/log_processor.rs | 2 -- 1 file changed, 2 deletions(-) diff --git a/opentelemetry-sdk/src/logs/log_processor.rs b/opentelemetry-sdk/src/logs/log_processor.rs index 3ca8f647af..7366f19791 100644 --- a/opentelemetry-sdk/src/logs/log_processor.rs +++ b/opentelemetry-sdk/src/logs/log_processor.rs @@ -522,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};