Skip to content

Commit 71f43e1

Browse files
committed
Avoid writing all endpoints to shared memory
1 parent 3747701 commit 71f43e1

File tree

2 files changed

+10
-11
lines changed

2 files changed

+10
-11
lines changed

datadog-sidecar/src/service/sidecar_server.rs

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ use std::collections::{HashMap, HashSet};
2828
use std::pin::Pin;
2929
use std::sync::atomic::{AtomicU64, Ordering};
3030
use std::sync::{Arc, Mutex};
31-
use std::time::Duration;
31+
use std::time::{Duration, SystemTime};
3232
use tracing::{debug, error, info, trace, warn};
3333

3434
use futures::FutureExt;
@@ -421,7 +421,7 @@ impl SidecarInterface for SidecarServer {
421421
},
422422
);
423423

424-
let mut actions_to_process = vec![];
424+
let mut actions_to_process: Vec<SidecarAction> = vec![];
425425
let mut composer_paths_to_process = vec![];
426426
let mut buffered_info_changed = false;
427427
let mut remove_entry = false;
@@ -449,12 +449,11 @@ impl SidecarInterface for SidecarServer {
449449
SidecarAction::ClearQueueId => {
450450
remove_entry = true;
451451
},
452-
SidecarAction::Telemetry(TelemetryActions::AddEndpoint(ref endpoint)) => {
453-
if telemetry.buffered_endpoints.insert(endpoint.clone()) {
454-
buffered_info_changed = true;
455-
actions_to_process.push(action);
456-
}
457-
},
452+
SidecarAction::Telemetry(TelemetryActions::AddEndpoint(_)) => {
453+
telemetry.last_endpoints_push = SystemTime::now();
454+
buffered_info_changed = true;
455+
actions_to_process.push(action);
456+
}
458457
SidecarAction::Telemetry(TelemetryActions::Lifecycle(
459458
LifecycleAction::Stop,
460459
)) => {

datadog-sidecar/src/service/telemetry.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ pub struct TelemetryCachedClient {
6262
pub config_sent: bool,
6363
pub buffered_integrations: HashSet<Integration>,
6464
pub buffered_composer_paths: HashSet<PathBuf>,
65-
pub buffered_endpoints: HashSet<ddtelemetry::data::Endpoint>,
65+
pub last_endpoints_push: SystemTime,
6666
pub telemetry_metrics: Arc<Mutex<HashMap<String, ContextKey>>>,
6767
pub handle: Arc<Mutex<Option<JoinHandle<()>>>>,
6868
}
@@ -100,7 +100,7 @@ impl TelemetryCachedClient {
100100
config_sent: false,
101101
buffered_integrations: HashSet::new(),
102102
buffered_composer_paths: HashSet::new(),
103-
buffered_endpoints: HashSet::new(),
103+
last_endpoints_push: SystemTime::UNIX_EPOCH,
104104
telemetry_metrics: Default::default(),
105105
handle: Arc::new(Mutex::new(None)),
106106
}
@@ -111,7 +111,7 @@ impl TelemetryCachedClient {
111111
&self.config_sent,
112112
&self.buffered_integrations,
113113
&self.buffered_composer_paths,
114-
&self.buffered_endpoints,
114+
&self.last_endpoints_push,
115115
)) {
116116
self.shm_writer.write(&buf);
117117
} else {

0 commit comments

Comments
 (0)