Skip to content

Commit c7c315b

Browse files
feat(info_fetcher): add timeout to info fetcher (#1890)
# What does this PR do? Use endpoint timeout in /info fetcher. # Motivation What inspired you to submit this pull request? # Additional Notes Anything else we should know when reviewing? # How to test the change? Describe here in detail how the change can be validated. Co-authored-by: vianney.ruhlmann <vianney.ruhlmann@datadoghq.com>
1 parent 5b798ae commit c7c315b

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

libdd-data-pipeline/src/agent_info/fetcher.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ use std::time::Duration;
2020
use tokio::sync::mpsc;
2121
use tokio::time::sleep;
2222
use tracing::{debug, warn};
23+
2324
/// Whether the agent reported the same value or not.
2425
#[derive(Debug)]
2526
pub enum FetchInfoStatus {
@@ -112,8 +113,11 @@ async fn fetch_and_hash_response<H: HttpClientTrait>(
112113
.body(Bytes::new())
113114
.map_err(|e| anyhow!("Failed to build request: {}", e))?;
114115

116+
let timeout = Duration::from_millis(info_endpoint.timeout_ms);
115117
let client = H::new_client();
116-
let res = client.request(req).await?;
118+
let res = tokio::time::timeout(timeout, client.request(req))
119+
.await
120+
.map_err(|_| anyhow!("Request to /info timed out after {:?}", timeout))??;
117121

118122
// Extract the Datadog-Container-Tags-Hash header
119123
let container_tags_hash = res

0 commit comments

Comments
 (0)