diff --git a/fastrace-futures/src/lib.rs b/fastrace-futures/src/lib.rs index af8b1e5..c876feb 100644 --- a/fastrace-futures/src/lib.rs +++ b/fastrace-futures/src/lib.rs @@ -104,8 +104,7 @@ pin_project! { } impl Stream for InSpan -where - T: Stream, +where T: Stream { type Item = T::Item; @@ -128,8 +127,7 @@ where } impl Sink for InSpan -where - T: Sink, +where T: Sink { type Error = T::Error; diff --git a/fastrace/examples/unit_test.rs b/fastrace/examples/unit_test.rs index 5636cf6..27f7754 100644 --- a/fastrace/examples/unit_test.rs +++ b/fastrace/examples/unit_test.rs @@ -31,9 +31,7 @@ mod test_util { use super::*; pub fn setup_fastrace(test: F) - where - F: FnOnce() -> Result<()> + 'static, - { + where F: FnOnce() -> Result<()> + 'static { fastrace::set_reporter(ConsoleReporter, Config::default()); { let root = Span::root(closure_name::(), SpanContext::random()); diff --git a/fastrace/src/collector/global_collector.rs b/fastrace/src/collector/global_collector.rs index 5d9aca3..18862e8 100644 --- a/fastrace/src/collector/global_collector.rs +++ b/fastrace/src/collector/global_collector.rs @@ -230,14 +230,16 @@ impl GlobalCollector { { std::thread::Builder::new() .name("fastrace-global-collector".to_string()) - .spawn(move || loop { - let begin_instant = Instant::now(); - GLOBAL_COLLECTOR.lock().as_mut().unwrap().handle_commands(); - std::thread::sleep( - config - .report_interval - .saturating_sub(begin_instant.elapsed()), - ); + .spawn(move || { + loop { + let begin_instant = Instant::now(); + GLOBAL_COLLECTOR.lock().as_mut().unwrap().handle_commands(); + std::thread::sleep( + config + .report_interval + .saturating_sub(begin_instant.elapsed()), + ); + } }) .unwrap(); } diff --git a/fastrace/src/local/local_span_line.rs b/fastrace/src/local/local_span_line.rs index 8a297f0..9bcc725 100644 --- a/fastrace/src/local/local_span_line.rs +++ b/fastrace/src/local/local_span_line.rs @@ -172,25 +172,22 @@ span1 [] let span = span_line.start_span("span").unwrap(); let current_token = span_line.current_collect_token().unwrap(); assert_eq!(current_token.len(), 2); - assert_eq!( - current_token.as_slice(), - &[ - CollectTokenItem { - trace_id: TraceId(1234), - parent_id: span_line.span_queue.current_parent_id().unwrap(), - collect_id: 42, - is_root: false, - is_sampled: true, - }, - CollectTokenItem { - trace_id: TraceId(1235), - parent_id: span_line.span_queue.current_parent_id().unwrap(), - collect_id: 43, - is_root: false, - is_sampled: true, - } - ] - ); + assert_eq!(current_token.as_slice(), &[ + CollectTokenItem { + trace_id: TraceId(1234), + parent_id: span_line.span_queue.current_parent_id().unwrap(), + collect_id: 42, + is_root: false, + is_sampled: true, + }, + CollectTokenItem { + trace_id: TraceId(1235), + parent_id: span_line.span_queue.current_parent_id().unwrap(), + collect_id: 43, + is_root: false, + is_sampled: true, + } + ]); span_line.finish_span(span); let current_token = span_line.current_collect_token().unwrap(); diff --git a/fastrace/src/local/local_span_stack.rs b/fastrace/src/local/local_span_stack.rs index c58e8eb..f3382cc 100644 --- a/fastrace/src/local/local_span_stack.rs +++ b/fastrace/src/local/local_span_stack.rs @@ -238,18 +238,20 @@ span1 [] { let span_line4 = span_stack.register_span_line(None).unwrap(); { - assert!(span_stack - .register_span_line(Some( - CollectTokenItem { - trace_id: TraceId(1235), - parent_id: SpanId::default(), - collect_id: 43, - is_root: false, - is_sampled: true, - } - .into() - )) - .is_none()); + assert!( + span_stack + .register_span_line(Some( + CollectTokenItem { + trace_id: TraceId(1235), + parent_id: SpanId::default(), + collect_id: 43, + is_root: false, + is_sampled: true, + } + .into() + )) + .is_none() + ); assert!(span_stack.register_span_line(None).is_none()); } let _ = span_stack.unregister_and_collect(span_line4).unwrap(); @@ -257,18 +259,20 @@ span1 [] { let span_line5 = span_stack.register_span_line(None).unwrap(); { - assert!(span_stack - .register_span_line(Some( - CollectTokenItem { - trace_id: TraceId(1236), - parent_id: SpanId::default(), - collect_id: 44, - is_root: false, - is_sampled: true, - } - .into() - )) - .is_none()); + assert!( + span_stack + .register_span_line(Some( + CollectTokenItem { + trace_id: TraceId(1236), + parent_id: SpanId::default(), + collect_id: 44, + is_root: false, + is_sampled: true, + } + .into() + )) + .is_none() + ); assert!(span_stack.register_span_line(None).is_none()); } let _ = span_stack.unregister_and_collect(span_line5).unwrap(); @@ -292,10 +296,9 @@ span1 [] is_sampled: true, }; let span_line1 = span_stack.register_span_line(Some(token1.into())).unwrap(); - assert_eq!( - span_stack.current_collect_token().unwrap().as_slice(), - &[token1] - ); + assert_eq!(span_stack.current_collect_token().unwrap().as_slice(), &[ + token1 + ]); { let span_line2 = span_stack.register_span_line(None).unwrap(); assert!(span_stack.current_collect_token().is_none()); @@ -308,10 +311,9 @@ span1 [] is_sampled: true, }; let span_line3 = span_stack.register_span_line(Some(token3.into())).unwrap(); - assert_eq!( - span_stack.current_collect_token().unwrap().as_slice(), - &[token3] - ); + assert_eq!(span_stack.current_collect_token().unwrap().as_slice(), &[ + token3 + ]); let _ = span_stack.unregister_and_collect(span_line3).unwrap(); } assert!(span_stack.current_collect_token().is_none()); @@ -325,16 +327,14 @@ span1 [] is_sampled: true, }; let span_line4 = span_stack.register_span_line(Some(token4.into())).unwrap(); - assert_eq!( - span_stack.current_collect_token().unwrap().as_slice(), - &[token4] - ); + assert_eq!(span_stack.current_collect_token().unwrap().as_slice(), &[ + token4 + ]); let _ = span_stack.unregister_and_collect(span_line4).unwrap(); } - assert_eq!( - span_stack.current_collect_token().unwrap().as_slice(), - &[token1] - ); + assert_eq!(span_stack.current_collect_token().unwrap().as_slice(), &[ + token1 + ]); let _ = span_stack.unregister_and_collect(span_line1).unwrap(); assert!(span_stack.current_collect_token().is_none()); } diff --git a/fastrace/src/span.rs b/fastrace/src/span.rs index 61ca557..69fea9b 100644 --- a/fastrace/src/span.rs +++ b/fastrace/src/span.rs @@ -725,10 +725,9 @@ root [] let parent4 = Span::root("parent4", parent_ctx); let parent5 = Span::root("parent5", parent_ctx); let child1 = Span::enter_with_parent("child1", &parent5); - let child2 = Span::enter_with_parents( - "child2", - [&parent1, &parent2, &parent3, &parent4, &parent5, &child1], - ) + let child2 = Span::enter_with_parents("child2", [ + &parent1, &parent2, &parent3, &parent4, &parent5, &child1, + ]) .with_property(|| ("k1", "v1")); crossbeam::scope(move |scope| { diff --git a/fastrace/src/util/object_pool.rs b/fastrace/src/util/object_pool.rs index ebb6131..7ac67dd 100644 --- a/fastrace/src/util/object_pool.rs +++ b/fastrace/src/util/object_pool.rs @@ -110,8 +110,7 @@ impl<'a, T> Reusable<'a, T> { } impl<'a, T> std::fmt::Debug for Reusable<'a, T> -where - T: std::fmt::Debug, +where T: std::fmt::Debug { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { self.obj.fmt(f) @@ -119,8 +118,7 @@ where } impl<'a, T> std::cmp::PartialEq for Reusable<'a, T> -where - T: std::cmp::PartialEq, +where T: std::cmp::PartialEq { fn eq(&self, other: &Self) -> bool { T::eq(self, other)