Skip to content

Commit

Permalink
Formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
Modularius committed Aug 29, 2024
1 parent 39a2cde commit 9b707f3
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 18 deletions.
12 changes: 9 additions & 3 deletions common/src/spanned.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,10 @@ pub trait SpannedMut: Spanned {
pub trait SpannedAggregator: SpannedMut {
fn span_init(&mut self) -> Result<(), SpanOnceError>;

fn link_current_span<F: Fn() -> Span>(&self, aggregated_span_fn: F) -> Result<(), SpanOnceError>;
fn link_current_span<F: Fn() -> Span>(
&self,
aggregated_span_fn: F,
) -> Result<(), SpanOnceError>;

fn end_span(&self) -> Result<(), SpanOnceError>;
}
Expand All @@ -112,8 +115,11 @@ pub trait FindSpan<T: SpannedAggregator + 'static> {
}
}

pub trait FindSpanMut<T : SpannedAggregator + 'static>: FindSpan<T> {
fn find_span_mut(&mut self, _key: <Self as FindSpan<T>>::Key) -> Option<&mut impl SpannedAggregator> {
pub trait FindSpanMut<T: SpannedAggregator + 'static>: FindSpan<T> {
fn find_span_mut(
&mut self,
_key: <Self as FindSpan<T>>::Key,
) -> Option<&mut impl SpannedAggregator> {
Option::<&mut T>::None
}
}
Expand Down
3 changes: 1 addition & 2 deletions digitiser-aggregator/src/frame/cache.rs
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -73,7 +73,6 @@ impl<D: Debug + 'static> FindSpanMut<PartialFrame<D>> for FrameCache<D> {
self.frames
.iter_mut()
.find(|frame| frame.metadata.equals_ignoring_veto_flags(&metadata))
.map(|frame| frame)
}
}

Expand Down
12 changes: 6 additions & 6 deletions digitiser-aggregator/src/frame/partial.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,11 @@ impl<D> SpannedAggregator for PartialFrame<D> {
.init(info_span!(target: "otel", parent: None, "Frame"))
}

fn link_current_span<F: Fn() -> Span>(&self, aggregated_span_fn: F) -> Result<(), SpanOnceError> {
let span = self
.span
.get()?
.in_scope(aggregated_span_fn);
fn link_current_span<F: Fn() -> 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(())
}
Expand All @@ -83,4 +83,4 @@ impl<D> SpannedAggregator for PartialFrame<D> {
.record("frame_is_expired", self.is_expired());
Ok(())
}
}
}
6 changes: 4 additions & 2 deletions digitiser-aggregator/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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}");
}
}
Expand Down
2 changes: 1 addition & 1 deletion nexus-writer/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
};
Expand Down
10 changes: 6 additions & 4 deletions nexus-writer/src/nexus/run.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
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::{
aev2_frame_assembled_event_v2_generated::FrameAssembledEventListMessage,
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,
Expand Down Expand Up @@ -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<F: Fn() -> Span>(&self, aggregated_span_fn: F) -> Result<(), SpanOnceError> {
fn link_current_span<F: Fn() -> Span>(
&self,
aggregated_span_fn: F,
) -> Result<(), SpanOnceError> {
self.span()
.get()?
.in_scope(aggregated_span_fn)
Expand Down

0 comments on commit 9b707f3

Please sign in to comment.