Skip to content

Commit

Permalink
rename to InternalFailure
Browse files Browse the repository at this point in the history
  • Loading branch information
cijothomas committed Jan 31, 2025
1 parent 2f8756e commit 2f074dd
Show file tree
Hide file tree
Showing 8 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion examples/metrics-basic/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ async fn main() {
Ok(_) => println!("MeterProvider shutdown successfully"),
Err(e) => {
match e {
opentelemetry_sdk::error::ShutdownError::Failed(e) => {
opentelemetry_sdk::error::ShutdownError::InternalFailure(e) => {
// This indicates some failure during shutdown.
// Not much to do here, but log the error.
// So users at least know something went wrong,
Expand Down
2 changes: 1 addition & 1 deletion opentelemetry-otlp/src/exporter/http/metrics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ impl MetricsClient for OtlpHttpClient {
self.client
.lock()
.map_err(|e| {
ShutdownError::Failed(format!("Internal Error. Failed to acquire lock: {}", e))
ShutdownError::InternalFailure(format!("Internal Error. Failed to acquire lock: {}", e))
})?
.take();

Expand Down
2 changes: 1 addition & 1 deletion opentelemetry-otlp/src/exporter/tonic/metrics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ impl MetricsClient for TonicMetricsClient {
self.inner
.lock()
.map_err(|e| {
ShutdownError::Failed(format!("Internal Error. Failed to acquire lock: {}", e))
ShutdownError::InternalFailure(format!("Internal Error. Failed to acquire lock: {}", e))
})?
.take();

Expand Down
2 changes: 1 addition & 1 deletion opentelemetry-sdk/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ pub enum ShutdownError {
/// Shutdown failed with an error.
/// This error is returned when the shutdown process failed with an error.
#[error("Shutdown failed: {0}")]
Failed(String),
InternalFailure(String),
}

/// A specialized `Result` type for Shutdown operations.
Expand Down
2 changes: 1 addition & 1 deletion opentelemetry-sdk/src/metrics/manual_reader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ impl MetricReader for ManualReader {
/// Closes any connections and frees any resources used by the reader.
fn shutdown(&self) -> ShutdownResult {
let mut inner = self.inner.lock().map_err(|e| {
ShutdownError::Failed(format!("Internal Error. Failed to acquire lock: {}", e))
ShutdownError::InternalFailure(format!("Internal Error. Failed to acquire lock: {}", e))
})?;

// Any future call to collect will now return an error.
Expand Down
6 changes: 3 additions & 3 deletions opentelemetry-sdk/src/metrics/periodic_reader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -405,22 +405,22 @@ impl PeriodicReaderInner {
let (response_tx, response_rx) = mpsc::channel();
self.message_sender
.send(Message::Shutdown(response_tx))
.map_err(|e| ShutdownError::Failed(e.to_string()))?;
.map_err(|e| ShutdownError::InternalFailure(e.to_string()))?;

// TODO: Make this timeout configurable.
match response_rx.recv_timeout(Duration::from_secs(5)) {
Ok(response) => {
if response {
Ok(())
} else {
Err(ShutdownError::Failed("Failed to shutdown".into()))
Err(ShutdownError::InternalFailure("Failed to shutdown".into()))
}
}
Err(mpsc::RecvTimeoutError::Timeout) => {
Err(ShutdownError::Timeout(Duration::from_secs(5)))
}
Err(mpsc::RecvTimeoutError::Disconnected) => {
Err(ShutdownError::Failed("Failed to shutdown".into()))
Err(ShutdownError::InternalFailure("Failed to shutdown".into()))
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion opentelemetry-sdk/src/metrics/pipeline.rs
Original file line number Diff line number Diff line change
Expand Up @@ -661,7 +661,7 @@ impl Pipelines {
if errs.is_empty() {
Ok(())
} else {
Err(crate::error::ShutdownError::Failed(format!("{errs:?}")))
Err(crate::error::ShutdownError::InternalFailure(format!("{errs:?}")))
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion opentelemetry-sdk/src/testing/metrics/metric_reader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ impl MetricReader for TestMetricReader {
let mut is_shutdown = self.is_shutdown.lock().unwrap();
*is_shutdown = true;
}
result.map_err(|e| crate::error::ShutdownError::Failed(e.to_string()))
result.map_err(|e| crate::error::ShutdownError::InternalFailure(e.to_string()))
}

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

0 comments on commit 2f074dd

Please sign in to comment.