From 72809362fb21125b0fbfe8b6b8fce23f37c822ed Mon Sep 17 00:00:00 2001 From: Lalit Kumar Bhasin Date: Mon, 12 Aug 2024 17:29:15 -0700 Subject: [PATCH] fix lint --- opentelemetry-appender-log/src/lib.rs | 2 +- opentelemetry-appender-tracing/src/layer.rs | 2 +- opentelemetry-sdk/benches/log.rs | 10 +++++----- opentelemetry-sdk/src/logs/mod.rs | 2 +- opentelemetry-stdout/src/logs/transform.rs | 4 ++-- 5 files changed, 10 insertions(+), 10 deletions(-) diff --git a/opentelemetry-appender-log/src/lib.rs b/opentelemetry-appender-log/src/lib.rs index 0b38968393..291f888488 100644 --- a/opentelemetry-appender-log/src/lib.rs +++ b/opentelemetry-appender-log/src/lib.rs @@ -128,7 +128,7 @@ where if self.enabled(record.metadata()) { let mut log_record = self.logger.create_log_record(); log_record.set_severity_number(severity_of_level(record.level())); - log_record.set_severity_text(record.level().as_str().into()); + log_record.set_severity_text(record.level().as_str()); log_record.set_body(AnyValue::from(record.args().to_string())); log_record.add_attributes(log_attributes(record.key_values())); log_record.set_target(record.metadata().target().to_string()); diff --git a/opentelemetry-appender-tracing/src/layer.rs b/opentelemetry-appender-tracing/src/layer.rs index 29eed63e8c..776dd27502 100644 --- a/opentelemetry-appender-tracing/src/layer.rs +++ b/opentelemetry-appender-tracing/src/layer.rs @@ -176,7 +176,7 @@ where log_record.set_target(meta.target().to_string()); log_record.set_event_name(meta.name()); log_record.set_severity_number(severity_of_level(meta.level())); - log_record.set_severity_text(meta.level().as_str().into()); + log_record.set_severity_text(meta.level().as_str()); let mut visitor = EventVisitor::new(&mut log_record); #[cfg(feature = "experimental_metadata_attributes")] visitor.visit_experimental_metadata(meta); diff --git a/opentelemetry-sdk/benches/log.rs b/opentelemetry-sdk/benches/log.rs index ba0a94cd17..198be8cf2f 100644 --- a/opentelemetry-sdk/benches/log.rs +++ b/opentelemetry-sdk/benches/log.rs @@ -131,7 +131,7 @@ fn logging_comparable_to_appender(c: &mut Criterion) { log_record.set_target("my-target".to_string()); log_record.set_event_name("CheckoutFailed"); log_record.set_severity_number(Severity::Warn); - log_record.set_severity_text("WARN".into()); + log_record.set_severity_text("WARN"); log_record.add_attribute("book_id", "12345"); log_record.add_attribute("book_title", "Rust Programming Adventures"); log_record.add_attribute("message", "Unable to process checkout."); @@ -275,7 +275,7 @@ fn criterion_benchmark(c: &mut Criterion) { log_record.set_timestamp(now); log_record.set_observed_timestamp(now); log_record.set_severity_number(Severity::Warn); - log_record.set_severity_text(Severity::Warn.name().into()); + log_record.set_severity_text(Severity::Warn.name()); logger.emit(log_record); }); @@ -285,7 +285,7 @@ fn criterion_benchmark(c: &mut Criterion) { log_record.set_timestamp(now); log_record.set_observed_timestamp(now); log_record.set_severity_number(Severity::Warn); - log_record.set_severity_text(Severity::Warn.name().into()); + log_record.set_severity_text(Severity::Warn.name()); log_record.add_attribute("name", "my-event-name"); log_record.add_attribute("event.id", 20); log_record.add_attribute("user.name", "otel"); @@ -299,7 +299,7 @@ fn criterion_benchmark(c: &mut Criterion) { log_record.set_timestamp(now); log_record.set_observed_timestamp(now); log_record.set_severity_number(Severity::Warn); - log_record.set_severity_text(Severity::Warn.name().into()); + log_record.set_severity_text(Severity::Warn.name()); log_record.add_attribute("name", "my-event-name"); log_record.add_attribute("event.id", 20); log_record.add_attribute("user.name", "otel"); @@ -338,7 +338,7 @@ fn criterion_benchmark(c: &mut Criterion) { log_record.set_timestamp(now); log_record.set_observed_timestamp(now); log_record.set_severity_number(Severity::Warn); - log_record.set_severity_text(Severity::Warn.name().into()); + log_record.set_severity_text(Severity::Warn.name()); log_record.add_attributes(attributes.clone()); logger.emit(log_record); }); diff --git a/opentelemetry-sdk/src/logs/mod.rs b/opentelemetry-sdk/src/logs/mod.rs index 207da4255c..5d2e72719b 100644 --- a/opentelemetry-sdk/src/logs/mod.rs +++ b/opentelemetry-sdk/src/logs/mod.rs @@ -41,7 +41,7 @@ mod tests { let logger = logger_provider.logger("test-logger"); let mut log_record = logger.create_log_record(); log_record.set_severity_number(Severity::Error); - log_record.set_severity_text("Error".into()); + log_record.set_severity_text("Error"); // Adding attributes using a vector with explicitly constructed Key and AnyValue objects. log_record.add_attributes(vec![ diff --git a/opentelemetry-stdout/src/logs/transform.rs b/opentelemetry-stdout/src/logs/transform.rs index 4e1b918137..0560e0c064 100644 --- a/opentelemetry-stdout/src/logs/transform.rs +++ b/opentelemetry-stdout/src/logs/transform.rs @@ -115,11 +115,11 @@ impl From for LogRecord { .collect::>(); // Collect into a Vecs #[cfg(feature = "populate-logs-event-name")] - if let Some(event_name) = &value.record.event_name { + if let Some(event_name) = value.record.event_name { let mut attributes_with_name = attributes; attributes_with_name.push(KeyValue::from(( "name".into(), - opentelemetry::Value::String(event_name.clone().into()), + opentelemetry::Value::String(event_name.into()), ))); attributes_with_name } else {