Skip to content
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

Provide default implementation for event_enabled trait in LogProcessor #2025

Merged
merged 3 commits into from
Aug 14, 2024
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
2 changes: 2 additions & 0 deletions opentelemetry-sdk/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
10 changes: 0 additions & 10 deletions opentelemetry-sdk/benches/log.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<F: Fn(&Logger)>(c: &mut Criterion, name: &str, f: F) {
Expand Down
1 change: 1 addition & 0 deletions opentelemetry-sdk/src/export/logs/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
10 changes: 0 additions & 10 deletions opentelemetry-sdk/src/logs/log_emitter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down Expand Up @@ -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
}
}
}
27 changes: 4 additions & 23 deletions opentelemetry-sdk/src/logs/log_processor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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) {}
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -162,11 +160,6 @@ impl<R: RuntimeChannel> LogProcessor for BatchLogProcessor<R> {
}
}

#[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
Expand Down Expand Up @@ -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};
Expand Down Expand Up @@ -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(())
}
Expand Down Expand Up @@ -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(())
}
Expand Down
9 changes: 0 additions & 9 deletions stress/src/logs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
Loading