Skip to content

Commit cb08c5f

Browse files
Copilotcijothomas
andcommitted
Fix code formatting with cargo fmt
Co-authored-by: cijothomas <[email protected]>
1 parent 965c4ff commit cb08c5f

File tree

2 files changed

+34
-19
lines changed

2 files changed

+34
-19
lines changed

opentelemetry-sdk/src/trace/span_processor.rs

Lines changed: 30 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -767,7 +767,7 @@ pub struct BatchConfig {
767767
pub(crate) max_concurrent_exports: usize,
768768

769769
/// Whether to export unsampled spans that are recording.
770-
/// If true, spans with is_recording() == true but TraceFlags::SAMPLED == false
770+
/// If true, spans with is_recording() == true but TraceFlags::SAMPLED == false
771771
/// will be exported. Defaults to false for backward compatibility.
772772
pub(crate) export_unsampled: bool,
773773
}
@@ -972,7 +972,9 @@ mod tests {
972972
use crate::trace::InMemorySpanExporterBuilder;
973973
use crate::trace::{BatchConfig, BatchConfigBuilder, SpanEvents, SpanLinks};
974974
use crate::trace::{SpanData, SpanExporter};
975-
use opentelemetry::trace::{SpanContext, SpanId, SpanKind, Status, TraceFlags, TraceId, TraceState};
975+
use opentelemetry::trace::{
976+
SpanContext, SpanId, SpanKind, Status, TraceFlags, TraceId, TraceState,
977+
};
976978
use std::fmt::Debug;
977979
use std::time::Duration;
978980

@@ -1479,7 +1481,7 @@ mod tests {
14791481
let exporter = MockSpanExporter::new();
14801482
let exporter_shared = exporter.exported_spans.clone();
14811483
let processor = BatchSpanProcessor::new(exporter, BatchConfig::default());
1482-
1484+
14831485
let unsampled_span = SpanData {
14841486
span_context: SpanContext::new(
14851487
TraceId::from(1),
@@ -1500,12 +1502,16 @@ mod tests {
15001502
status: Status::Unset,
15011503
instrumentation_scope: Default::default(),
15021504
};
1503-
1505+
15041506
processor.on_end(unsampled_span);
15051507
processor.force_flush().unwrap();
1506-
1508+
15071509
let exported_spans = exporter_shared.lock().unwrap();
1508-
assert_eq!(exported_spans.len(), 0, "Unsampled spans should not be exported by default");
1510+
assert_eq!(
1511+
exported_spans.len(),
1512+
0,
1513+
"Unsampled spans should not be exported by default"
1514+
);
15091515
}
15101516

15111517
#[test]
@@ -1516,7 +1522,7 @@ mod tests {
15161522
.with_export_unsampled(true)
15171523
.build();
15181524
let processor = BatchSpanProcessor::new(exporter, config);
1519-
1525+
15201526
let unsampled_span = SpanData {
15211527
span_context: SpanContext::new(
15221528
TraceId::from(1),
@@ -1537,12 +1543,16 @@ mod tests {
15371543
status: Status::Unset,
15381544
instrumentation_scope: Default::default(),
15391545
};
1540-
1546+
15411547
processor.on_end(unsampled_span);
15421548
processor.force_flush().unwrap();
1543-
1549+
15441550
let exported_spans = exporter_shared.lock().unwrap();
1545-
assert_eq!(exported_spans.len(), 1, "Unsampled spans should be exported when export_unsampled is enabled");
1551+
assert_eq!(
1552+
exported_spans.len(),
1553+
1,
1554+
"Unsampled spans should be exported when export_unsampled is enabled"
1555+
);
15461556
assert_eq!(exported_spans[0].name, "unsampled_span");
15471557
assert!(!exported_spans[0].span_context.is_sampled());
15481558
}
@@ -1555,7 +1565,7 @@ mod tests {
15551565
.with_export_unsampled(true)
15561566
.build();
15571567
let processor = BatchSpanProcessor::new(exporter, config);
1558-
1568+
15591569
// Add a sampled span
15601570
let sampled_span = SpanData {
15611571
span_context: SpanContext::new(
@@ -1577,7 +1587,7 @@ mod tests {
15771587
status: Status::Unset,
15781588
instrumentation_scope: Default::default(),
15791589
};
1580-
1590+
15811591
// Add an unsampled span
15821592
let unsampled_span = SpanData {
15831593
span_context: SpanContext::new(
@@ -1599,14 +1609,18 @@ mod tests {
15991609
status: Status::Unset,
16001610
instrumentation_scope: Default::default(),
16011611
};
1602-
1612+
16031613
processor.on_end(sampled_span);
16041614
processor.on_end(unsampled_span);
16051615
processor.force_flush().unwrap();
1606-
1616+
16071617
let exported_spans = exporter_shared.lock().unwrap();
1608-
assert_eq!(exported_spans.len(), 2, "Both sampled and unsampled spans should be exported when export_unsampled is enabled");
1609-
1618+
assert_eq!(
1619+
exported_spans.len(),
1620+
2,
1621+
"Both sampled and unsampled spans should be exported when export_unsampled is enabled"
1622+
);
1623+
16101624
let span_names: Vec<&str> = exported_spans.iter().map(|s| s.name.as_ref()).collect();
16111625
assert!(span_names.contains(&"sampled_span"));
16121626
assert!(span_names.contains(&"unsampled_span"));

opentelemetry-sdk/src/trace/span_processor_with_async_runtime.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -385,9 +385,10 @@ impl<R: RuntimeChannel> BatchSpanProcessor<R> {
385385
runtime.spawn(async move {
386386
// Timer will take a reference to the current runtime, so its important we do this within the
387387
// runtime.spawn()
388-
let ticker = to_interval_stream(inner_runtime.clone(), config_for_worker.scheduled_delay)
389-
.skip(1) // The ticker is fired immediately, so we should skip the first one to align with the interval.
390-
.map(|_| BatchMessage::Flush(None));
388+
let ticker =
389+
to_interval_stream(inner_runtime.clone(), config_for_worker.scheduled_delay)
390+
.skip(1) // The ticker is fired immediately, so we should skip the first one to align with the interval.
391+
.map(|_| BatchMessage::Flush(None));
391392
let timeout_runtime = inner_runtime.clone();
392393

393394
let messages = Box::pin(stream::select(message_receiver, ticker));

0 commit comments

Comments
 (0)