Skip to content

Commit ad94202

Browse files
committed
fmt
1 parent 2f074dd commit ad94202

File tree

5 files changed

+24
-14
lines changed

5 files changed

+24
-14
lines changed

opentelemetry-otlp/src/exporter/http/metrics.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,10 @@ impl MetricsClient for OtlpHttpClient {
4848
self.client
4949
.lock()
5050
.map_err(|e| {
51-
ShutdownError::InternalFailure(format!("Internal Error. Failed to acquire lock: {}", e))
51+
ShutdownError::InternalFailure(format!(
52+
"Internal Error. Failed to acquire lock: {}",
53+
e
54+
))
5255
})?
5356
.take();
5457

opentelemetry-otlp/src/exporter/tonic/metrics.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,10 @@ impl MetricsClient for TonicMetricsClient {
9494
self.inner
9595
.lock()
9696
.map_err(|e| {
97-
ShutdownError::InternalFailure(format!("Internal Error. Failed to acquire lock: {}", e))
97+
ShutdownError::InternalFailure(format!(
98+
"Internal Error. Failed to acquire lock: {}",
99+
e
100+
))
98101
})?
99102
.take();
100103

opentelemetry-sdk/src/metrics/periodic_reader_with_async_runtime.rs

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,7 @@ impl<RT: Runtime> PeriodicReaderWorker<RT> {
297297
let res = self.collect_and_export().await;
298298
let _ = self.reader.exporter.shutdown();
299299
if let Err(send_error) =
300-
ch.send(res.map_err(|e| ShutdownError::Failed(e.to_string())))
300+
ch.send(res.map_err(|e| ShutdownError::InternalFailure(e.to_string())))
301301
{
302302
otel_debug!(
303303
name: "PeriodicReader.Shutdown.SendResultError",
@@ -379,9 +379,10 @@ impl MetricReader for PeriodicReader {
379379
}
380380

381381
fn shutdown(&self) -> ShutdownResult {
382-
let mut inner = self.inner.lock().map_err(|e| {
383-
ShutdownError::Failed(format!("Internal Error. Failed to acquire lock: {}", e))
384-
})?;
382+
let mut inner = self
383+
.inner
384+
.lock()
385+
.map_err(|e| ShutdownError::InternalFailure(e.to_string()))?;
385386
if inner.is_shutdown {
386387
return Err(ShutdownError::AlreadyShutdown);
387388
}
@@ -390,16 +391,17 @@ impl MetricReader for PeriodicReader {
390391
inner
391392
.message_sender
392393
.try_send(Message::Shutdown(sender))
393-
.map_err(|e| ShutdownError::Failed(e.to_string()))?;
394+
.map_err(|e| ShutdownError::InternalFailure(e.to_string()))?;
394395
drop(inner); // don't hold lock when blocking on future
395396

396397
let shutdown_result = futures_executor::block_on(receiver)
397-
.map_err(|err| ShutdownError::Failed(err.to_string()))?;
398+
.map_err(|err| ShutdownError::InternalFailure(err.to_string()))?;
398399

399400
// Acquire the lock again to set the shutdown flag
400-
let mut inner = self.inner.lock().map_err(|e| {
401-
ShutdownError::Failed(format!("Internal Error. Failed to acquire lock: {}", e))
402-
})?;
401+
let mut inner = self
402+
.inner
403+
.lock()
404+
.map_err(|e| ShutdownError::InternalFailure(e.to_string()))?;
403405
inner.is_shutdown = true;
404406

405407
shutdown_result

opentelemetry-sdk/src/metrics/pipeline.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -661,7 +661,9 @@ impl Pipelines {
661661
if errs.is_empty() {
662662
Ok(())
663663
} else {
664-
Err(crate::error::ShutdownError::InternalFailure(format!("{errs:?}")))
664+
Err(crate::error::ShutdownError::InternalFailure(format!(
665+
"{errs:?}"
666+
)))
665667
}
666668
}
667669
}

opentelemetry-sdk/src/testing/metrics/metric_reader.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use std::sync::{Arc, Mutex, Weak};
22

3-
use crate::error::ShutdownResult;
3+
use crate::error::{ShutdownError, ShutdownResult};
44
use crate::metrics::{
55
data::ResourceMetrics, pipeline::Pipeline, reader::MetricReader, InstrumentKind,
66
};
@@ -48,7 +48,7 @@ impl MetricReader for TestMetricReader {
4848
let mut is_shutdown = self.is_shutdown.lock().unwrap();
4949
*is_shutdown = true;
5050
}
51-
result.map_err(|e| crate::error::ShutdownError::InternalFailure(e.to_string()))
51+
result.map_err(|e| ShutdownError::InternalFailure(e.to_string()))
5252
}
5353

5454
fn temporality(&self, _kind: InstrumentKind) -> Temporality {

0 commit comments

Comments
 (0)