Skip to content

Commit

Permalink
PeriodicReader shutdown modified to enforce timeout (open-telemetry#2513
Browse files Browse the repository at this point in the history
)
  • Loading branch information
cijothomas authored Jan 15, 2025
1 parent 5aa9120 commit f46bccc
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions opentelemetry-sdk/src/metrics/periodic_reader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -415,14 +415,21 @@ impl PeriodicReaderInner {
.send(Message::Shutdown(response_tx))
.map_err(|e| MetricError::Other(e.to_string()))?;

if let Ok(response) = response_rx.recv() {
if response {
Ok(())
} else {
// TODO: Make this timeout configurable.
match response_rx.recv_timeout(Duration::from_secs(5)) {
Ok(response) => {
if response {
Ok(())
} else {
Err(MetricError::Other("Failed to shutdown".into()))
}
}
Err(mpsc::RecvTimeoutError::Timeout) => Err(MetricError::Other(
"Failed to shutdown due to Timeout".into(),
)),
Err(mpsc::RecvTimeoutError::Disconnected) => {
Err(MetricError::Other("Failed to shutdown".into()))
}
} else {
Err(MetricError::Other("Failed to shutdown".into()))
}
}
}
Expand Down

0 comments on commit f46bccc

Please sign in to comment.