Skip to content

Commit 3efc1a9

Browse files
Clear aggregator queue when API key resolution fails to avoid retries… (#785)
Clear aggregator queue when API key resolution fails to avoid retries and prevent wasted billing time. Test: | Scenario | Log | Observation | |--------|--------|--------| | Baseline+good DD_API_KEY | REPORT RequestId: cac9fb53-c84f-4c4b-b5fb-f2965589e559 **Duration: 126.62 ms Billed Duration: 127 ms** Memory Size: 1024 MB Max Memory Used: 94 MB | Normal | |Baseline+bad DD_API_KEY|REPORT RequestId: bfff6cc0-3ab2-4a35-86a5-0ba29d1ba1d6 **Duration: 120000.00 ms Billed Duration: 120000 ms** Memory Size: 1024 MB Max Memory Used: 90 MB Status: timeout|Time out with excessive billed time| |Change+good DD_API_KEY|REPORT RequestId: 58ef36bf-7b05-47da-8173-a204d0c74ff6 **Duration: 46.62 ms Billed Duration: 47 ms** Memory Size: 1024 MB Max Memory Used: 94 MB|Normal| |Change+bad DD_API_KEY|REPORT RequestId: 333cd454-6765-4817-98d9-95a9b754f567 **Duration: 67.33 ms Billed Duration: 68 ms** Memory Size: 1024 MB Max Memory Used: 94 MB|Fail fast w/o excessive billed time| [Tracking records](https://docs.google.com/spreadsheets/d/1G7Lq7e1Apr43beDQh6J4ekonixDMXWLImhYv90Umbls/edit?gid=831661199#gid=831661199)
1 parent 9b458bc commit 3efc1a9

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

bottlecap/src/traces/proxy_aggregator.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,4 +30,9 @@ impl Aggregator {
3030
pub fn get_batch(&mut self) -> Vec<ProxyRequest> {
3131
std::mem::take(&mut self.queue)
3232
}
33+
34+
/// Flush the queue.
35+
pub fn clear(&mut self) {
36+
self.queue.clear();
37+
}
3338
}

bottlecap/src/traces/proxy_flusher.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,13 @@ impl Flusher {
8282
retry_requests: Option<Vec<reqwest::RequestBuilder>>,
8383
) -> Option<Vec<reqwest::RequestBuilder>> {
8484
let Some(api_key) = self.api_key_factory.get_api_key().await else {
85-
error!("Skipping flush in proxy flusher: Failed to resolve API key");
85+
error!(
86+
"Purging the aggregated data and skipping flush in proxy flusher: Failed to resolve API key."
87+
);
88+
{
89+
let mut aggregator = self.aggregator.lock().await;
90+
aggregator.clear();
91+
}
8692
return None;
8793
};
8894

0 commit comments

Comments
 (0)