From ecba965549d17048c48b764ecdcca379180ca4db Mon Sep 17 00:00:00 2001 From: Igor Aleksanov Date: Thu, 1 Aug 2024 10:40:09 +0400 Subject: [PATCH] Lints --- core/lib/vlog/src/lib.rs | 6 ++---- core/lib/vlog/src/opentelemetry/mod.rs | 18 +++++++----------- 2 files changed, 9 insertions(+), 15 deletions(-) diff --git a/core/lib/vlog/src/lib.rs b/core/lib/vlog/src/lib.rs index ffdf70e8a66b..48b02c6958a6 100644 --- a/core/lib/vlog/src/lib.rs +++ b/core/lib/vlog/src/lib.rs @@ -130,13 +130,11 @@ impl ObservabilityBuilder { let (otlp_tracing_provider, otlp_tracing_layer) = self .opentelemetry_layer .as_ref() - .map(|layer| layer.tracing_layer()) - .flatten() + .and_then(|layer| layer.tracing_layer()) .unzip(); let (otlp_logging_provider, otlp_logging_layer) = self .opentelemetry_layer - .map(|layer| layer.logs_layer()) - .flatten() + .and_then(|layer| layer.logs_layer()) .unzip(); tracing_subscriber::registry() diff --git a/core/lib/vlog/src/opentelemetry/mod.rs b/core/lib/vlog/src/opentelemetry/mod.rs index e8e07399881d..a5ff6477f738 100644 --- a/core/lib/vlog/src/opentelemetry/mod.rs +++ b/core/lib/vlog/src/opentelemetry/mod.rs @@ -91,10 +91,11 @@ impl ServiceDescriptor { } fn into_otlp_resource(self) -> Resource { - let mut attributes = vec![]; - attributes.push(KeyValue::new(K8S_POD_NAME, self.k8s_pod_name)); - attributes.push(KeyValue::new(K8S_NAMESPACE_NAME, self.k8s_namespace_name)); - attributes.push(KeyValue::new(SERVICE_NAME, self.service_name)); + let attributes = vec![ + KeyValue::new(K8S_POD_NAME, self.k8s_pod_name), + KeyValue::new(K8S_NAMESPACE_NAME, self.k8s_namespace_name), + KeyValue::new(SERVICE_NAME, self.service_name), + ]; Resource::new(attributes) } } @@ -164,10 +165,7 @@ impl OpenTelemetry { where S: tracing::Subscriber + for<'span> LookupSpan<'span> + Send + Sync, { - let Some(logging_endpoint) = self.logging_endpoint.clone() else { - return None; - }; - + let logging_endpoint = self.logging_endpoint.clone()?; let resource = self.service.clone().into_otlp_resource(); let exporter = opentelemetry_otlp::new_exporter() @@ -195,9 +193,7 @@ impl OpenTelemetry { where S: tracing::Subscriber + for<'span> LookupSpan<'span> + Send + Sync, { - let Some(tracing_endpoint) = self.tracing_endpoint.clone() else { - return None; - }; + let tracing_endpoint = self.tracing_endpoint.clone()?; // `otel::tracing` should be a level info to emit opentelemetry trace & span // `otel` set to debug to log detected resources, configuration read and inferred let filter = self