Skip to content

Commit 94817d7

Browse files
Copilotcijothomas
andcommitted
Remove unnecessary Mutex from SimpleSpanProcessor after SpanExporter trait changes
Co-authored-by: cijothomas <[email protected]>
1 parent 6dfee01 commit 94817d7

File tree

1 file changed

+5
-19
lines changed

1 file changed

+5
-19
lines changed

opentelemetry-sdk/src/trace/span_processor.rs

Lines changed: 5 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -116,15 +116,13 @@ pub trait SpanProcessor: Send + Sync + std::fmt::Debug {
116116
/// emitted from a tokio runtime thread.
117117
#[derive(Debug)]
118118
pub struct SimpleSpanProcessor<T: SpanExporter> {
119-
exporter: Mutex<T>,
119+
exporter: T,
120120
}
121121

122122
impl<T: SpanExporter> SimpleSpanProcessor<T> {
123123
/// Create a new [SimpleSpanProcessor] using the provided exporter.
124124
pub fn new(exporter: T) -> Self {
125-
Self {
126-
exporter: Mutex::new(exporter),
127-
}
125+
Self { exporter }
128126
}
129127
}
130128

@@ -138,11 +136,7 @@ impl<T: SpanExporter> SpanProcessor for SimpleSpanProcessor<T> {
138136
return;
139137
}
140138

141-
let result = self
142-
.exporter
143-
.lock()
144-
.map_err(|_| OTelSdkError::InternalFailure("SimpleSpanProcessor mutex poison".into()))
145-
.and_then(|exporter| futures_executor::block_on(exporter.export(vec![span])));
139+
let result = futures_executor::block_on(self.exporter.export(vec![span]));
146140

147141
if let Err(err) = result {
148142
// TODO: check error type, and log `error` only if the error is user-actionable, else log `debug`
@@ -159,19 +153,11 @@ impl<T: SpanExporter> SpanProcessor for SimpleSpanProcessor<T> {
159153
}
160154

161155
fn shutdown_with_timeout(&self, timeout: Duration) -> OTelSdkResult {
162-
if let Ok(exporter) = self.exporter.lock() {
163-
exporter.shutdown_with_timeout(timeout)
164-
} else {
165-
Err(OTelSdkError::InternalFailure(
166-
"SimpleSpanProcessor mutex poison at shutdown".into(),
167-
))
168-
}
156+
self.exporter.shutdown_with_timeout(timeout)
169157
}
170158

171159
fn set_resource(&mut self, resource: &Resource) {
172-
if let Ok(mut exporter) = self.exporter.lock() {
173-
exporter.set_resource(resource);
174-
}
160+
self.exporter.set_resource(resource);
175161
}
176162
}
177163

0 commit comments

Comments
 (0)