Skip to content

Commit 75e08bd

Browse files
committed
atomicusize, remove proessor mutex
1 parent 3bbd91a commit 75e08bd

File tree

1 file changed

+7
-14
lines changed

1 file changed

+7
-14
lines changed

opentelemetry-sdk/src/logs/log_processor.rs

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -553,10 +553,8 @@ mod tests {
553553
use opentelemetry::InstrumentationLibrary;
554554
use opentelemetry::Key;
555555
use opentelemetry::{logs::LogResult, KeyValue};
556-
use std::sync::{
557-
atomic::{AtomicU32, Ordering},
558-
Arc, Mutex,
559-
};
556+
use std::sync::atomic::{AtomicUsize, Ordering};
557+
use std::sync::{Arc, Mutex};
560558
use std::time::Duration;
561559

562560
#[derive(Debug, Clone)]
@@ -1019,20 +1017,15 @@ mod tests {
10191017
#[tokio::test(flavor = "multi_thread")]
10201018
async fn test_simple_processor_sync_exporter_with_multi_thread_runtime() {
10211019
let exporter = InMemoryLogsExporterBuilder::default().build();
1022-
let processor = Arc::new(Mutex::new(SimpleLogProcessor::new(Box::new(
1023-
exporter.clone(),
1024-
))));
1020+
let processor = Arc::new(SimpleLogProcessor::new(Box::new(exporter.clone())));
10251021

10261022
let mut handles = vec![];
10271023
for _ in 0..10 {
10281024
let processor_clone = Arc::clone(&processor);
10291025
let handle = tokio::spawn(async move {
10301026
let mut record: LogRecord = Default::default();
10311027
let instrumentation: InstrumentationLibrary = Default::default();
1032-
processor_clone
1033-
.lock()
1034-
.unwrap()
1035-
.emit(&mut record, &instrumentation);
1028+
processor_clone.emit(&mut record, &instrumentation);
10361029
});
10371030
handles.push(handle);
10381031
}
@@ -1059,20 +1052,20 @@ mod tests {
10591052

10601053
#[derive(Debug, Clone)]
10611054
struct LogExporterThatRequiresTokio {
1062-
export_count: Arc<AtomicU32>,
1055+
export_count: Arc<AtomicUsize>,
10631056
}
10641057

10651058
impl LogExporterThatRequiresTokio {
10661059
/// Creates a new instance of `LogExporterThatRequiresTokio`.
10671060
fn new() -> Self {
10681061
LogExporterThatRequiresTokio {
1069-
export_count: Arc::new(AtomicU32::new(0)),
1062+
export_count: Arc::new(AtomicUsize::new(0)),
10701063
}
10711064
}
10721065

10731066
/// Returns the number of logs stored in the exporter.
10741067
fn len(&self) -> usize {
1075-
self.export_count.load(Ordering::Acquire) as usize
1068+
self.export_count.load(Ordering::Acquire)
10761069
}
10771070
}
10781071

0 commit comments

Comments
 (0)