Skip to content

Commit 54893d8

Browse files
authored
Merge branch 'main' into cijothomas/remove-redundant-shutdownche
2 parents aed1daf + f46bccc commit 54893d8

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

opentelemetry-sdk/src/metrics/periodic_reader.rs

+13-6
Original file line numberDiff line numberDiff line change
@@ -415,14 +415,21 @@ impl PeriodicReaderInner {
415415
.send(Message::Shutdown(response_tx))
416416
.map_err(|e| MetricError::Other(e.to_string()))?;
417417

418-
if let Ok(response) = response_rx.recv() {
419-
if response {
420-
Ok(())
421-
} else {
418+
// TODO: Make this timeout configurable.
419+
match response_rx.recv_timeout(Duration::from_secs(5)) {
420+
Ok(response) => {
421+
if response {
422+
Ok(())
423+
} else {
424+
Err(MetricError::Other("Failed to shutdown".into()))
425+
}
426+
}
427+
Err(mpsc::RecvTimeoutError::Timeout) => Err(MetricError::Other(
428+
"Failed to shutdown due to Timeout".into(),
429+
)),
430+
Err(mpsc::RecvTimeoutError::Disconnected) => {
422431
Err(MetricError::Other("Failed to shutdown".into()))
423432
}
424-
} else {
425-
Err(MetricError::Other("Failed to shutdown".into()))
426433
}
427434
}
428435
}

0 commit comments

Comments
 (0)