From 9b707f37c8dc120dae5aa5471a2fa19acbb63e79 Mon Sep 17 00:00:00 2001 From: Modularius Date: Thu, 29 Aug 2024 14:48:09 +0000 Subject: [PATCH] Formatting --- common/src/spanned.rs | 12 +++++++++--- digitiser-aggregator/src/frame/cache.rs | 3 +-- digitiser-aggregator/src/frame/partial.rs | 12 ++++++------ digitiser-aggregator/src/main.rs | 6 ++++-- nexus-writer/src/main.rs | 2 +- nexus-writer/src/nexus/run.rs | 10 ++++++---- 6 files changed, 27 insertions(+), 18 deletions(-) diff --git a/common/src/spanned.rs b/common/src/spanned.rs index 2604d0d2..95739889 100644 --- a/common/src/spanned.rs +++ b/common/src/spanned.rs @@ -97,7 +97,10 @@ pub trait SpannedMut: Spanned { pub trait SpannedAggregator: SpannedMut { fn span_init(&mut self) -> Result<(), SpanOnceError>; - fn link_current_span Span>(&self, aggregated_span_fn: F) -> Result<(), SpanOnceError>; + fn link_current_span Span>( + &self, + aggregated_span_fn: F, + ) -> Result<(), SpanOnceError>; fn end_span(&self) -> Result<(), SpanOnceError>; } @@ -112,8 +115,11 @@ pub trait FindSpan { } } -pub trait FindSpanMut: FindSpan { - fn find_span_mut(&mut self, _key: >::Key) -> Option<&mut impl SpannedAggregator> { +pub trait FindSpanMut: FindSpan { + fn find_span_mut( + &mut self, + _key: >::Key, + ) -> Option<&mut impl SpannedAggregator> { Option::<&mut T>::None } } diff --git a/digitiser-aggregator/src/frame/cache.rs b/digitiser-aggregator/src/frame/cache.rs index b80943ac..ecc19357 100644 --- a/digitiser-aggregator/src/frame/cache.rs +++ b/digitiser-aggregator/src/frame/cache.rs @@ -1,7 +1,7 @@ use crate::data::{Accumulate, DigitiserData}; use std::{collections::VecDeque, fmt::Debug, time::Duration}; use supermusr_common::{ - spanned::{FindSpan, FindSpanMut, SpanOnce, SpannedAggregator, SpannedMut}, + spanned::{FindSpan, FindSpanMut, SpannedAggregator}, DigitizerId, }; use supermusr_streaming_types::FrameMetadata; @@ -73,7 +73,6 @@ impl FindSpanMut> for FrameCache { self.frames .iter_mut() .find(|frame| frame.metadata.equals_ignoring_veto_flags(&metadata)) - .map(|frame| frame) } } diff --git a/digitiser-aggregator/src/frame/partial.rs b/digitiser-aggregator/src/frame/partial.rs index 399ae5b0..b29f1389 100644 --- a/digitiser-aggregator/src/frame/partial.rs +++ b/digitiser-aggregator/src/frame/partial.rs @@ -67,11 +67,11 @@ impl SpannedAggregator for PartialFrame { .init(info_span!(target: "otel", parent: None, "Frame")) } - fn link_current_span Span>(&self, aggregated_span_fn: F) -> Result<(), SpanOnceError> { - let span = self - .span - .get()? - .in_scope(aggregated_span_fn); + fn link_current_span Span>( + &self, + aggregated_span_fn: F, + ) -> Result<(), SpanOnceError> { + let span = self.span.get()?.in_scope(aggregated_span_fn); span.follows_from(tracing::Span::current()); Ok(()) } @@ -83,4 +83,4 @@ impl SpannedAggregator for PartialFrame { .record("frame_is_expired", self.is_expired()); Ok(()) } -} \ No newline at end of file +} diff --git a/digitiser-aggregator/src/main.rs b/digitiser-aggregator/src/main.rs index 38c5a0c5..0678b6c1 100644 --- a/digitiser-aggregator/src/main.rs +++ b/digitiser-aggregator/src/main.rs @@ -189,8 +189,10 @@ async fn on_message( error!("Tracing error: {e}"); } } - - if let Err(e) = frame_span.link_current_span(||info_span!(target: "otel", "Digitiser Event List")) { + + if let Err(e) = frame_span.link_current_span( + || info_span!(target: "otel", "Digitiser Event List"), + ) { error!("Tracing error: {e}"); } } diff --git a/nexus-writer/src/main.rs b/nexus-writer/src/main.rs index 48c8f269..e075454e 100644 --- a/nexus-writer/src/main.rs +++ b/nexus-writer/src/main.rs @@ -17,7 +17,7 @@ use supermusr_common::{ messages_received::{self, MessageKind}, metric_names::{FAILURES, MESSAGES_PROCESSED, MESSAGES_RECEIVED}, }, - spanned::{Spanned, SpannedAggregator, SpannedMut}, + spanned::SpannedAggregator, tracer::{OptionalHeaderTracerExt, TracerEngine, TracerOptions}, CommonKafkaOpts, }; diff --git a/nexus-writer/src/nexus/run.rs b/nexus-writer/src/nexus/run.rs index e5398c8c..be83b7dc 100644 --- a/nexus-writer/src/nexus/run.rs +++ b/nexus-writer/src/nexus/run.rs @@ -1,6 +1,5 @@ use super::{hdf5_file::RunFile, NexusSettings, RunParameters}; use chrono::{DateTime, Duration, Utc}; -use tracing::{info_span, Span}; use std::path::Path; use supermusr_common::spanned::{SpanOnce, SpanOnceError, Spanned, SpannedAggregator, SpannedMut}; use supermusr_streaming_types::{ @@ -8,6 +7,7 @@ use supermusr_streaming_types::{ ecs_6s4t_run_stop_generated::RunStop, ecs_al00_alarm_generated::Alarm, ecs_f144_logdata_generated::f144_LogData, ecs_se00_data_generated::se00_SampleEnvironmentData, }; +use tracing::{info_span, Span}; pub(crate) struct Run { span: SpanOnce, @@ -160,11 +160,13 @@ impl SpannedMut for Run { impl SpannedAggregator for Run { fn span_init(&mut self) -> Result<(), SpanOnceError> { let span = info_span!(target: "otel", parent: None, "Run"); - self.span_mut() - .init(span) + self.span_mut().init(span) } - fn link_current_span Span>(&self, aggregated_span_fn: F) -> Result<(), SpanOnceError> { + fn link_current_span Span>( + &self, + aggregated_span_fn: F, + ) -> Result<(), SpanOnceError> { self.span() .get()? .in_scope(aggregated_span_fn)